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 方法将这些属性声明为字符串数组。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);