1826677 Members
2740 Online
109696 Solutions
New Discussion

Service Restart

 
SOLVED
Go to solution
Kathir Lakshmanan
Honored Contributor

Service Restart

How does the service restart works?

I have a Service pointing to a script /etc/cmcluster//abc.mon and the RESTART is set to "-r 1"

Inisde the script it goes in a loop and checks for certain processes if they are not running, it breaks out of the loop stops the app and starts the application.

My question is, does the script need to return a exit code of 0 or 1, so that the RESTART count will increase or is it sufficient when the loop is broken it comes out of the script to bump the RESTART COUNT Value?

Thanks,
Kathir
7 REPLIES 7
melvyn burnard
Honored Contributor

Re: Service Restart

The Srvice Restart i sthere to restart your script in case it dies.
The way a Service is used is that you set up a script to do an infinite loop to check for the existence of required processes, for example the Oracle log writer.
If one of your specific application processes goes missing, your script should exit with an exit value of say 1.
The Service Manager then sees this, and if there is a Restart value set AND the count has not dropped to 0, the Service Manager will restart that service (i.e. your script)
If there is no restart value or it has dropped to a 0, the Service Manager notifies the Package mmanager that a the service has died, and this causes the Package Manager to halt the package and attempt to switch it to an alternate node.

All documented in the Managing Serviceguard manual available from http://docs.hp.com/en/ha
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
Kevin Wright
Honored Contributor

Re: Service Restart

script should not exit, unless the processes are not running. Restart count cannot be changed within your script, that is defined in the pkg config.

Kathir Lakshmanan
Honored Contributor

Re: Service Restart

I understand that the count is specified in the pkg cntl file. The part I dont understand is - The script goes in a loop, check for availability of processes, but when it doesnt find one of the process, then it breaks out of the loop and should it restart and then return a exit 1 for the Restart count to increase? or the exit 1 is not necessary??

-Kathir
Kathir Lakshmanan
Honored Contributor

Re: Service Restart

If anyone can post a sample mon script with proper exit options, that would be great...

-Kathir
BPatrick
Trusted Contributor

Re: Service Restart

Kathir,
A monitor script for oracle db package is attached.

Regards
Patrick
Carsten Krege
Honored Contributor
Solution

Re: Service Restart

It does not play a role how the service script exits. SG monitors the process. If it exits for any reason and the maximum restart value is not reached yet it will try to restart it, otherwise it would halt the package on the node.

It does not play a role if the service script exits with return value 0 or 1 or anything else. As soon as it exits, SG takes action. The restart counter is increased with every exit.

This is different to the package control script where indeed various exit codes have different meaning:

0 - clean exit
1 - exit with NO_RESTART
2 - exit with RESTART (e.g. dependent EMS resource not available)

Carsten
-------------------------------------------------------------------------------------------------
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move. -- HhGttG
Kathir Lakshmanan
Honored Contributor

Re: Service Restart

See the previous post