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