Managing HP Serviceguard for Linux, Sixth Edition, August 2006

Configuring Packages and Their Services
Writing the Package Control Script
Chapter 6 203
# You should define all actions you want to happen here, before the
service is
# halted.
function customer_defined_halt_cmds
{
# ADD customer defined halt commands.
: # do nothing instruction, because a function must contain some
command.
date >> /tmp/pkg1.datelog
echo 'Halting pkg1' >> /tmp/pkg1.datelog
test_return 52
}
# END OF CUSTOMER DEFINED FUNCTIONS
Adding Serviceguard Commands in Customer Defined Functions
You can add Serviceguard commands (such as cmmodpkg) in the
Customer Defined Functions section of a package control script.
However, these commands must not interact with the package itself.
Additionally, if a Serviceguard command interacts with another package,
then you need to check all packages with Serviceguard commands for the
possibility of a command loop.
For instance, a command loop might occur under the following
circumstances. Suppose Pkg1 does a cmmodpkg -d of Pkg2, and Pkg2
does a cmmodpkg -d of Pkg1. If both Pkg1 and Pkg2 start at the same
time, Pkg1 tries to cmmodpkg Pkg2. However, that cmmodpkg command
has to wait for Pkg2 startup to complete. Pkg2 tries to cmmodpkg Pkg1,
but Pkg2 has to wait for Pkg1 startup to complete, thereby causing a
command loop.
To avoid this situation, it is a good idea to always specify a
RUN_SCRIPT_TIMEOUT and a HALT_SCRIPT_TIMEOUT for all packages,
especially packages that use Serviceguard commands in their control
scripts. If a timeout is not specified and your configuration has a
command loop as described above, inconsistent results can occur,
including a hung cluster.
Adding or Removing Packages on a Running Cluster
You can add or remove packages while the cluster is running, subject to
the limit of MAX_CONFIGURED_PACKAGES. To add or remove packages
online, refer to the chapter on “Cluster and Package Maintenance.”