cancel
Showing results for 
Search instead for 
Did you mean: 

Package Halt Script problems

Andrew Underhill
Occasional Advisor

Package Halt Script problems

MC/SG 11.14

When a packaged is halted on a node, SG fires a SIGTERM at the services to advise them that they are to shutdown.

I have a package/service that suffere when this happens. The service receives the SIGTERM, and cascades it down to the processes that the service started, terminating them before the service can shut them down gracefully.

I've tried using "trap" to catch the SIGTERM, but have not had any joy.

Can anyone advise?
5 REPLIES 5
steven Burgess_2
Honored Contributor

Re: Package Halt Script problems

Hi Andrew

What method are you using to stop and start your service ? Do you let service guard stop and start the 'actual' service via the SERVICE_NAME and customer_defined_run_cmds or are you specify a path to a run script which looks after the monitoring and start/shutdown of the service ?

Steve
take your time and think things through
Andrew Underhill
Occasional Advisor

Re: Package Halt Script problems

The services are defined in the SERVICE_ lines with the full path to the service script. The script is given at this point the start command e.g.

SERVICE_CMD[4]="/etc/cmcluster/autosys/autosys.sh start"

There are no customer defined run commands, but the are customer defined halt commands, e..g

/etc/cmcluster/autosys/autosys.sh halt


The start command starts the required processes and then monitors them, if any fail, the script exits, which MCSG detects and restarts the service script as appropriate.

The customer halt commands stop these processes gracefully, unfortunately the SIGTERM is getting through that MCSG sends when the package needs to halted for whatever reason. Ideally I need to stop that SIGTERM from cascading.

Cheers
Stephen Doud
Honored Contributor

Re: Package Halt Script problems

Look at the bottom of the package control script. You will see these functions called in this order when the package control script is called with a "stop" option by a cmhaltpkg command:

halt_services

customer_defined_halt_cmds

Note that the SERVICEs are halted prior to performing the customer_defined_halt_cmds. This probably explains why your service is being terminated prematurely before the ...halt_cmds has a chance to do it the way you like. Your monitor script should take this into account.

-StephenD.



Gary L. Paveza, Jr.
Trusted Contributor

Re: Package Halt Script problems

It appears that you're mixing functionality. You are using the SERVICE to start the service, but the halt function to stop it.

You should add a function to your autosys.sh script for monitoring. This can be as simple as sending a kill -0 every few minutes. If you get a nonzero return code, then fail the monitor. Let's call this function monitor

Then your SERVICE should be autosys.sh monitor.

In customer defined run commands, you would have autosys.sh start

In customer defined halt commands, you would have autosys.sh halt.
melvyn burnard
Honored Contributor

Re: Package Halt Script problems

Message contains a hyperlink
You seem to have a conflict here. You start your processes as a SERVICE, but then halt them as an application in th euser definde halt commands.

You need to change this and have the applications started using the user defined run commands function.
If you wish to have a SERVICE monitoring these processes, then you need a further section in your script that you call with a different keyword from stop and start, like monitor, and then use your script with the monitor keyword in your SERVICE command line.

I suggest a good read through the Managing Serviceguard manual at http://docs.hp.com/en/ha may also give you assistance here.
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!