此方法使用进程管理器工具 (pmfadm) 来启动应用程序。 pmfadm 允许您设置在指定时间内重启应用程序的次数。 RTR 文件中包含两个特性 Retry_count 和 Retry_interval,分别用来指定尝试重启应用程序的次数和两次重启操作之间的时间间隔。
Start 方法将使用 scha_resource_get() 函数检索 Retry_count 和 Retry_interval 的值,并将这些值存储在 shell 变量中。 然后使用 -n 和 -t 选项将这些值传送到 pmfadm。
# Get the value for retry count from the RTR file. RETRY_CNT=`scha_resource_get -O Retry_Count -R $RESOURCE_NAME \ -G $RESOURCEGROUP_NAME` # Get the value for retry interval from the RTR file. This value is in seconds # and must be converted to minutes for passing to pmfadm. Note that the # conversion rounds up; for example, 50 seconds rounds up to 1 minute. ((RETRY_INTRVAL=`scha_resource_get -O Retry_Interval -R $RESOURCE_NAME \ -G $RESOURCEGROUP_NAME` / 60)) # Start the in.named daemon under the control of PMF. Let it crash and restart # up to $RETRY_COUNT times in a period of $RETRY_INTERVAL; if it crashes # more often than that, PMF will cease trying to restart it. # If there is a process already registered under the tag # <$PMF_TAG>, then PMF sends out an alert message that the # process is already running. pmfadm -c $PMF_TAAG -n $RETRY_CNT -t $RETRY_INTRVAL \ /usr/sbin/in.named -c named.conf # Log a message indicating that HA-DNS has been started. if [ $? -eq 0 ]; then logger -p ${SYSLOG_FACILITY}.err \ -t [$SYSLOG_TAG] \ "${ARGV0} HA-DNS successfully started" fi exit 0 |