xfnts_start 方法呼叫在 xfnts.c 中定義的 svc_start() 方法來啟動 xfs 常駐程式。 本節說明了 svc_start ()。
用來啟動 xfs 常駐程式的指令如下所述。
xfs -config config_directory/fontserver.cfg -port port_number |
Confdir_list 延伸屬性識別 config_directory,而 Port_list 系統屬性識別 port_number。 當叢集管理員配置資料服務時,他會為這些屬性提供特定值。
xfnts_start 方法將這些屬性宣告為字串陣列,並使用 scds_get_ext_confdir_list() 與 scds_get_port_list() 函式 (在 scds_property_functions(3HA) 中有說明) 取得管理員設定的值,如下所示。
scha_str_array_t *confdirs; scds_port_list_t *portlist; scha_err_t err; /* get the configuration directory from the confdir_list property */ confdirs = scds_get_ext_confdir_list(scds_handle); (void) sprintf(xfnts_conf, "%s/fontserver.cfg", confdirs->str_array[0]); /* obtain the port to be used by XFS from the Port_list property */ err = scds_get_port_list(scds_handle, &portlist); if (err != SCHA_ERR_NOERR) { scds_syslog(LOG_ERR, "Could not access property Port_list."); return (1); }
請注意,confdirs 變數指陣列的第一個元素 (0)。
xfnts_start 方法使用 sprintf 來產生 xfs 的指令行,如下所示。
/* Construct the command to start the xfs daemon. */ (void) sprintf(cmd, "/usr/openwin/bin/xfs -config %s -port %d 2>/dev/null", xfnts_conf, portlist->ports[0].port);
請注意,他的輸出將重新導向至 dev/null,來抑制此常駐程式產生的訊息。
xfnts_start 方法將 xfs 指令行傳送至 scds_pmf_start(),以啟動 PMF 控制下的資料服務,如下所示。
scds_syslog(LOG_INFO, "Issuing a start request."); err = scds_pmf_start(scds_handle, SCDS_PMF_TYPE_SVC, SCDS_PMF_SINGLE_INSTANCE, cmd, -1); if (err == SCHA_ERR_NOERR) { scds_syslog(LOG_INFO, "Start command completed successfully."); } else { scds_syslog(LOG_ERR, "Failed to start HA-XFS "); }
請注意關於 scds_pmf_start() 呼叫的以下內容。
SCDS_PMF_TYPE_SVC 參數將要啟動的程式識別為資料服務應用程式 — 此方法也可以啟動故障監視器或某些其他類型的應用程式。
SCDS_PMF_SINGLE_INSTANCE 參數將其識別為單一實例資源。
cmd 參數是先前產生的指令行。
最終參數 -1 指定子監視層次。 -1 指定 PMF 監視所有子程序及原始程序。
在傳回前,svc_pmf_start() 將釋放為 portlist 結構分配的記憶體空間,如下所示。
scds_free_port_list(portlist); return (err); |