Sun Cluster 数据服务开发者指南(适用于 Solaris OS)

使用 svc_start() 启动服务

xfnts_start 方法将调用在 xfnts.c 文件中定义的 svc_start() 方法来启动 xfs 守护进程。本节将介绍 svc_start ()

用于启动 xfs 守护进程的命令如下:


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

Confdir_list 扩展属性用于标识 config-directoryPort_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);