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

使用 svc_start() 啟動服務

xfnts_start 方法將呼叫 svc_start() 方法 (在 xfnts.c 檔案中定義) 以啟動 xfs 常駐程式。本節說明 svc_start()

用於啟動 xfs 常駐程式的指令如下所示︰


# xfs -config config-directory/fontserver.cfg -port port-number

Confdir_list 延伸特性識別 config-directory 時,Port_list 系統特性識別 port-number。當叢集管理員配置資料服務時,將為這些特性提供特定值。

xfnts_start 方法宣告這些特性為字串陣列。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() 呼叫的幾點內容︰

傳回之前,svc_pmf_start() 將釋放為 portlist 結構配置的記憶體。

scds_free_port_list(portlist);
return (err);