StopCommand

By default, the StopCommand is executed synchronously by System Automation for Multiplatforms, meaning that System Automation for Multiplatforms waits for the command to finish and obtain knowledge of any return code. Furthermore there is an attribute StopCommandTimeout for each resource which determines how long it takes at most to execute the StopCommand. If the StopCommand does not return within the StopCommandTimeout time period, the StopCommand is killed by System Automation for Multiplatforms using the SIGKILL command. If this happens a message is logged into the system log of that node.

If the StopCommand for a resource has been executed but the OpState of the resource does not change to Offline within the Offline timeout period, System Automation for Multiplatforms issues a reset operation against the resource. The Offline timeout period (in seconds) for a resource is calculated using the following formula:
MAX(StopCommandTimeout, MonitorCommandPeriod, MonitorCommandTimeout) + 5

Note that + 5 is not an absolute value as System Automation for Multiplatforms does not use a real timer. The System Automation for Multiplatforms daemons are woken up frequently, and this may result in the additional value, which may be in the range of 5 to 8 seconds.

Issuing a reset operation against a resource results in a second execution of the StopCommand, but this time a special environment variable (SA_RESET) is set to 1. This can be exploited within the StopCommand of a resource to achieve an enhanced force behavior, for example:
#/bin/sh
# A sample stop/reset automation script for the lpd application
if [ $SA_RESET -eq 1 ]; then
  killall -9 lpd
  exit $?
else
  /etc/init.d/lpd stop
  exit $?
fi 
If a second execution of the StopCommand is not desired, the script could just exit, for example:
#/bin/sh
# A sample stop/reset automation script for the lpd application
if [ $SA_RESET == 1 ]; then
  exit 0
else
  /etc/init.d/lpd stop
  exit $?
fi 

If the resource still does not stop after the second execution of the StopCommand, the OpState of the resource is set to Stuck Online, which means that manual intervention is now required to stop the resource. System Automation for Multiplatforms will resume automating the resource only after the problem has been resolved by an operator.

A manual reset now causes a stop command to run for all specified resources. If the resetrsrc command is executed without specifying the NodeNameList attribute within the selection string, the stop command will be executed against all resources. If only the resource name is specified in the selection string for a floating resource, the stop command is executed for each constituent as well as for the aggregate resource, as the selection string comprises the aggregate resource and the constituent resources. As stop command handling for the aggregate resource itself is delegated to all of the constituent resources, all constituent resources will execute the stop command twice. This is why it is recommended that you specify the NodeNameList attribute whenever resetrsrc is executed within the selection string of the command.