실행 및 종료

본 장에서는 호스트 매니저를 실행 및 종료하는 방법에 대해서 설명한다.

1. 호스트 매니저 시작 및 종료

1.1. 호스트 매니저 시작

호스트 매니저는 스크립트를 통해서 실행시킨다. SUPERFRAME_HOME/bin 하위에 존재하는 startHostManager를 실행시키면 다음과 같이 호스트 매니저가 마스터로부터 명령어를 받아 인스턴스를 관리할 준비를 한다. 이때 config 디렉터리의 hostmanager.yml에 필요한 설정을 마친 후 스크립트를 실행한다.

SUPERFRAME_HOME/bin$ startHostManager
[2023.04.25 10:00:02][2] [c.t.h.ServerApplication] [main] Starting ServerApplication using Java 1.8.0_362 on ubuntu with PID 222090 (/home/tmax/test/hostmanager/lib/hostmanager-0.4.2.jar started by tmax in /home/tmax/test/hostmanager/bin)
[2023.04.25 10:00:02][2] [c.t.h.ServerApplication] [main] No active profile set, falling back to 1 default profile: "default"
[2023.04.25 10:00:03][2] [c.t.h.c.HostConfigurationSource] [main] Applied host properties: HostProperties(rootDir=/home/tmax/test/hostmanager, address=192.168.1.1, port=7730)
[2023.04.25 10:00:03][2] [c.t.h.c.HostConfigurationSource] [main] Applied environment variables(password covered): {JEUS_HOME=/home/tmax/test/jeus, JEUS_USERNAME=jeus}
[2023.04.25 10:00:04][2] [c.t.h.r.e.RuntimeEnginesInfo] [main] Detected engines: [JEUS]
[2023.04.25 10:00:06][2] [c.t.h.ServerApplication] [main] Started ServerApplication in 3.883 seconds (JVM running for 4.399)
[2023.04.25 10:00:06][2] [c.t.h.c.i.ProjectInformationPrinter] [main] Starting hostmanager version 0.4.2 with platform SUPERFRAME.
[2023.04.25 10:00:06][2] [c.t.h.r.RuntimeProcessLoader] [main] Starting to recover instances if exist...
[2023.04.25 10:00:06][2] [c.t.h.ServerApplication] [main] Host manager started.

호스트 매니저가 인스턴스를 모니터링하는 중에 종료되어 다시 기동되었다면 이전에 모니터링하던 인스턴스를 계속 모니터링하기 위한 작업을 한다. 이때는 다음과 같은 로그가 발생한다.

SUPERFRAME_HOME/bin$ startHostManager
[2023.04.25 10:05:02][2] [c.t.h.ServerApplication] [main] Starting ServerApplication using Java 1.8.0_362 on ubuntu with PID 222090 (/home/tmax/test/hostmanager/lib/hostmanager-0.4.2.jar started by tmax in /home/tmax/test/hostmanager/bin)
[2023.04.25 10:05:02][2] [c.t.h.ServerApplication] [main] No active profile set, falling back to 1 default profile: "default"
[2023.04.25 10:05:03][2] [c.t.h.c.HostConfigurationSource] [main] Applied host properties: HostProperties(rootDir=/home/tmax/test/hostmanager, address=192.168.1.1, port=7730)
[2023.04.25 10:05:03][2] [c.t.h.c.HostConfigurationSource] [main] Applied environment variables(password covered): {JEUS_HOME=/home/tmax/test/jeus, JEUS_USERNAME=jeus}
[2023.04.25 10:05:04][2] [c.t.h.r.e.RuntimeEnginesInfo] [main] Detected engines: [JEUS]
[2023.04.25 10:05:06][2] [c.t.h.ServerApplication] [main] Started ServerApplication in 3.883 seconds (JVM running for 4.399)
[2023.04.25 10:05:06][2] [c.t.h.c.i.ProjectInformationPrinter] [main] Starting hostmanager version 0.4.2 with platform SUPERFRAME.
[2023.04.25 10:05:06][2] [c.t.h.r.RuntimeProcessLoader] [main] Starting to recover instances if exist...
[2023.04.25 10:05:16][2] [c.t.h.r.RuntimeManager] [main] The instance testInstance with pid 69425 is recovered as monitored process.
[2023.04.25 10:05:18][2] [c.t.h.r.RuntimeManager] [main] The instance testInstance2 with pid 12345 is not alive.
[2023.04.25 10:05:22][2] [c.t.h.r.RuntimeProcessLoader] [main] Instance testInstance2 will not be restarted.
[2023.04.25 10:05:22][2] [c.t.h.ServerApplication] [main] Host manager started.

1.2. 호스트 매니저 종료

호스트 매니저를 종료하기 위해서는 스크립트를 사용한다.

다음과 같이 stopHostManager를 실행하면 호스트 매니저가 종료된다.

SUPERFRAME_HOME/bin$ stopHostManager -host 192.168.1.1:7730
Trying to stop hostmanager.
[2023.04.24 17:57:29][2] [c.t.h.c.ShutdownController] [XNIO-1 task-1] Hostmanager shutdown is requested...

만약 다음과 같은 에러 메시지가 발생한다면, curl 설치가 필요하다.

Trying to stop hostmanager.
/home/tmax/test/hostmanager/bin/stopHostManager[48]: curl:  not found