The Stop method provides a two-tiered approach to stopping the data service: an orderly or smooth approach using a SIGTERM signal through pmfadm and an abrupt or hard approach using a SIGKILL signal. The Stop method obtains the Stop_timeout value (the amount of time in which the Stop method must return). Stop then allocates 80% of this time to stopping smoothly and 15% to stopping abruptly (5% is reserved), as shown in the following sample.
STOP_TIMEOUT=`scha_resource_get -O STOP_TIMEOUT -R $RESOURCE_NAME \ -G $RESOURCEGROUP_NAMÈ ((SMOOTH_TIMEOUT=$STOP_TIMEOUT * 80/100)) ((HARD_TIMEOUT=$STOP_TIMEOUT * 15/100))
The Stop method uses pmfadm -q to verify that the DNS daemon is running. If it is, Stop first uses pmfadm -s to send a TERM signal to terminate the DNS process. If this signal fails to terminate the process after 80% of the timeout value has expired Stop sends a SIGKILL signal. If this signal also fails to terminate the process within 15% of the timeout value, the method logs an error message and exits with error status.
If pmfadm terminates the process, the method logs a message that the process has stopped and exits with success.
If the DNS process is not running, the method logs a message that it is not running and exits with success anyway. The following code sample shows how Stop uses pmfadm to stop the DNS process.
# See if in.named is running, and if so, kill it. if pmfadm -q $PMF_TAG; then # Send a SIGTERM signal to the data service and wait for 80% of the # total timeout value. pmfadm -s $RESOURCE_NAME.named -w $SMOOTH_TIMEOUT TERM if [ $? -ne 0 ]; then logger -p ${SYSLOG_FACILITY}.err \ -t [$RESOURCETYPE_NAME,$RESOURCEGROUP_NAME,$RESOURCE_NAME] \ “${ARGV0} Failed to stop HA-DNS with SIGTERM; Retry with \ SIGKILL” # Since the data service did not stop with a SIGTERM signal, use # SIGKILL now and wait for another 15% of the total timeout value. pmfadm -s $PMF_TAG -w $HARD_TIMEOUT KILL if [ $? -ne 0 ]; then logger -p ${SYSLOG_FACILITY}.err \ -t [$SYSLOG_TAG] “${ARGV0} Failed to stop HA-DNS; Exiting UNSUCCESFUL” exit 1 fi fi else # The data service is not running as of now. Log a message and # exit success. logger -p ${SYSLOG_FACILITY}.err \ -t [$SYSLOG_TAG] \ “HA-DNS is not started” # Even if HA-DNS is not running, exit success to avoid putting # the data service resource in STOP_FAILED State. exit 0 fi # Could successfully stop DNS. Log a message and exit success. logger -p ${SYSLOG_FACILITY}.err \ -t [$RESOURCETYPE_NAME,$RESOURCEGROUP_NAME,$RESOURCE_NAME] \ “HA-DNS successfully stopped” exit 0 |