Java Server Systemd로 실행하기
/etc/systemd/system/myapp.service 만들어서 아래 내용 추가
설명)
상태확인
$> systemctl status {service_name.service}
실행
$> systemctl start {service_name.service}
중지
$> systemctl stop {service_name.service}
재실행
$> systemctl restart {service_name.service}
실행중인 서비스 확인
$> systemctl list-units --type=service
1 2 3 4 5 6 7 8 9 10 11 12 13 | [Unit] Description=Run Java server [Service] WorkingDirectory=/home/server ExecStart=/usr/bin/java -jar /home/server/myapp.jar User=myserver Type=simple Restart=on-failure RestartSec=10 [Install] WantedBy=multi-user.target |
- Description: 설명 입력.
- WorkingDirectory: 서버 실행할 디렉토리.
- ExecStart: 실행 명령어. 반드시 절대경로로 표시.
- User: 실행할 사용자 계정.
- Type: 실행 타입. 자세한 내용은 systemd를 참조.
- Restart: 재시작 조건.
- RestartSec: restart 실행 간격.
- WantedBy: 선행 조건.
상태확인
$> systemctl status {service_name.service}
실행
$> systemctl start {service_name.service}
중지
$> systemctl stop {service_name.service}
재실행
$> systemctl restart {service_name.service}
실행중인 서비스 확인
$> systemctl list-units --type=service
댓글
댓글 쓰기