Sun Cluster 資料服務開發者指南 (適用於 Solaris 作業系統)

啟動應用程式

此方法使用程序管理員功能 (pmfadm) 啟動應用程式。pmfadm 指令可讓您設定在指定的時間框架內可以嘗試重新啟動應用程式的次數。RTR 檔案含有兩個特性︰Retry_count 指定嘗試重新啟動某一應用程式的次數,而 Retry_interval 則指定嘗試重新啟動某一應用程式的時間期間。

Start 方法透過使用 scha_resource_get () 函數擷取 Retry_count Retry_interval 的值並將這些值儲存於 shell 變數中。Start 方法透過使用 -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