Andreas_Sprosec_7439

BestPractice / Start Servicemanager

Discussion created by Andreas_Sprosec_7439 on Jun 19, 2017
You Asked

Looking for insight on setting up start up script for Automic Application (Servicemanager) without using 'nohup'.

And we said ...

When you execute a Unix job in the background ( using &, bg command), and logout from the session, your process will get killed. You can avoid this using several methods — executing the job with nohup, or making it as batch job using at, batch or cron command.

e.g.: You can use at command to queue a job for later execution. For example, you can run my.sh script to queue (one minute) later execution:
$ echo "my.sh" | at now + 1 minute

A quick guide to the boot process
When you boot your computer, the first thing that it will do is load the bootloader -- either GRUB or LILO in most cases. The bootloader will then load the Linux kernel -- the core operating system. Next, a process called init starts. This process reads the file /etc/inittab to establish the runlevel to use. The runlevel is the start mode for the computer.

Once init knows the runlevel it will look for the appropriate files or directories as defined in /etc/initab.

Init will then either run the script files defined by /etc/initab, or run the script files in the directories defined by /etc/initab (depending on the set up of your system).

Finally, init will present you with the logon mode that you've selected.

Let's start by looking at how the system is set up, and in particular at the directory /etc/rc.d. Here you will find either a set of files named rc.0, rc.1, rc.2, rc.3, rc.4, rc.5, and rc.6, or a set of directories named rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d, and rc6.d. You will also find a file named /etc/inittab. The system uses these files (and/or directories) to control the services to be started.

If you look in the file /etc/inittab you will see something like:

id:5:initdefault:l
0:0:wait:/etc/rc.d/rc.0l
6:6:wait:/etc/rc.d/rc.6x
1:4:wait:/etc/rc.d/rc.4

The boot process uses these parameters to identify the default runlevel and the files that will be used by that runlevel. In this example, runlevel 5 is the default and the scripts that define runlevel 5 can be found in /etc/rc.d/rc.5.

e.g.:
-rwxr-xr-x 1 root root   1772 Oct  7  2016 automicsm.bak
lrwxrwxrwx 1 root root 12 Oct  7  2016 ./rc5.d/K01automicsm -> ../automicsm
lrwxrwxrwx 1 root root 12 Oct  7  2016 ./rc5.d/S08automicsm -> ../automicsm

And what is a runlevel? You might assume that this refers to different levels that the system goes through during a boot up. Instead, think of the runlevel as the point at which the system is entered. Runlevel 1 is the most basic configuration (simple single user access using an text interface), while runlevel 5 is the most advanced (multi-user, networking, and a GUI front end). Runlevels 0 and 6 are used for halting and rebooting the system.

There are, however, differences between Linux distributions!
For instance, Fedora uses runlevel 5 for X-based logins, whereas Slackware uses runlevel 4 to do the same job. Therefore, you should check your documentation.


In our Support Department we use a script which we starts manually to avoid any strange, unascertained errors with the Automation Engine after the service manager started successfully but than a 'but' occurs (e.g: owner of the service manager process is the Root-User which shouldn't be. Strongly recommended in our documentation).

Execute the script with the flags method use following arguments (Bash enables this functionality with the "getopts" function):

         -e     Name of the Environment File
         -m     Modus of the Automation Engine (start|stop|restart)

e.g.: sup@vwgsup14:/uc4> ./AE_start.sh -e .SO11_env -m start

1) Output on the screen
d34tmx7uew95.png
2) Write a log file
7kz8gw8wmgtv.png
3) Error handling
    If a parameter is missing or one of the variables are not set following message will be shown:
w5rlv1vu81bh.png 
To setup the environment the variables are defined in a file (.SO11_env - unfortunately we cannot attache this file because of the restrictions in the community platform):

PHRASE=SO11
AE_HOME=/uc4/SO11
DAEMON=ucybsmgr
DAEMONOPTS="-iucybsmgr.ini ${PHRASE}"
BINPATH=$AE_HOME/ServiceManager/bin
BINLOG=$AE_HOME/ServiceManager/temp
LOGFILE=${PHRASE}.log
PIDFILE=/var/run/${BINLOG}.pid

ORACLE_HOME=/home/uc4/oracle/product/12.1.0/client_1
ORACLE_BASE=/u01/app/oracle
NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P15
LD_LIBRARY_PATH=.:/uc4:/uc4/SO11/utility/bin:$ORACLE_HOME/lib
JRE_HOME=/usr/java/jdk1.7.0_75/jre
JAVA_HOME=/usr/java/jdk1.7.0_75/jre

export PHRASE AE_HOME DAEMON DAEMONOPTS BINPATH BINLOG ORACLE_HOME ORACLE_BASE NLS_LANG PATH LD_LIBRARY_PATH JAVA_HOME JRE_HOME

Attachments

Outcomes