On Linux and UNIX platforms, there are two different ways of ensuring that certain system jobs or 'daemons' start and stop at respectively system initiation and system termination:
The latter process is what we describe here. Some of the information presented could be used to construct scripts utilizing the first deployment method.
In order to start up TDI daemon processes when the UNIX/Linux OS starts appropriate entries must be added to the /etc/inittab file. The registering of TDI as a windows service on Windows translates to adding a line of text to the /etc/inittab file on UNIX/Linux. The un-installation of the TDI windows service on Windows translates to removing the corresponding entries from the /etc/inittab file. For each TDI daemon process that needs to be started on system startup one line of text must be added to the /etc/inittab file. The format and meaning of the entries in this file is described below. Each entry in the /etc/inittab file has the following format:
Identifier:RunLevel:Action:Command
A description of each of these fields is as follows:
The RunLevel field can define multiple run-levels for a process by selecting more than one run-level in any combination from 0 through N. For example, if TDIneeds to run in run-level 3 and 6, then the run-level must be specified as "36". If no run-level is specified, the process is assumed to be valid at all run-levels.
It is recommended that no run-level numbers are specified, unless the specific TDI solution specifically needs to.
When the init command enters a run-level that matches the entry's run level, start the process, and do not wait for its termination. When it dies, do not restart the process. When the system enters a new run level, and the process is still running from a previous run level change, the program not be restarted. All subsequent reads of the/etc/inittab file while the init command is in the same run level cause the init command to ignore this entry.
Here are three example TDI-related entries in /etc/inittab:
tdi1::once:/opt/IBM/TDI71_1/ibmdisrv -c "/opt/IBM/TDI71_1/myconfigs/rs1.xml" -r "testAL1" tdi2::once:/opt/IBM/TDI71_2/ibmdisrv -c "/opt/IBM/TDI71_2/myconfigs/rs2.xml" -r "testAL2" tdi3::once:/opt/IBM/TDI71_3/ibmdisrv -c "/opt/IBM/TDI71_3/myconfigs/rs3.xml" -r "testAL3"
This example starts three TDI server instances which are installed in different folders.
There are some differences in the different UNIX/Linux operating systems for system startup. That is why the information provided here covers the main issues of starting IBM TDI on a UNIX/Linux system and does not refer to any specific UNIX/Linux system.
As an example of an /etc/inittab file, detailed information about the /etc/inittab configuration file for an AIX system can be found at http://publib16.boulder.ibm.com/pseries/en_US/files/aixfiles/inittab.htm
Graceful shutdown
On UNIX systems we always perform a graceful shutdown of the service. This is achieved by a shutdown hook added to the Java Runtime. That way, when the server is stopped with either SIGINT or SIGTERM signals, this hook is executed and the server is gracefully terminated.
Another advantage of this approach is that this hook will be invoked on all platforms when the server is stopped by pressing CTRL+C in its console window.
We can also specify an external program to be started from within the JVM shutdown Hook. This external program is configured using an optional property in the global.properties or solution.properties file: jvm.shutdown.hook. If configured the external program will be started right after the server has shutdown gracefully.