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); |