Ubuntu systemd service 만들기
다음과 같은 명령어를 하나의 service로 작성하려 한다.
java `cat conf-quickstart/druid/historical/jvm.config | xargs` -cp "conf-quickstart/druid/_common:conf-quickstart/druid/historical:lib/*" io.druid.cli.Main server historical
systemd service를 만들기 위해선 총 두개의 step이 필요하다.
- 먼저 명령어를 .sh 파일로 만들어준다.
- .sh를 이용해 .service 파일을 만들어 systemd에 service로 등록한다.
1. .sh 파일 만들기
/opt/shell/druid 라는 폴더를 만들어, 그 폴더에 .sh 파일들을 모두 생성해주었다.
sample) broker.sh
#!/usr/bin/env bash
cd /opt/druid
/usr/bin/java `cat conf-quickstart/druid/broker/jvm.config | xargs` -cp "conf-quickstart/druid/_common:conf-quickstart/druid/broker:lib/*" io.druid.cli.Main server broker
2. .service 파일 만들기
/lib/systemd/system/ 에 .service 파일을 생성해 주었다.
sample) druid-broker.service
[Unit]
Description=Druid broker
[Service]
WorkingDirectory=/opt/druid
ExecStart=/opt/shell/druid/broker.sh
Type=simple
User=ubuntu
Restart=always
[Install]
WantedBy=multi-user.target
3. service 시작하기
다음 명령어로 service를 시작할 수 있다.
sudo service druid-broker start
다음 명령어로 service의 상태를 확인할 수 있다.
service druid-broker status
참고자료 : https://pinedance.github.io/blog/2017/09/12/Ubuntu-16.04-system-service-%EB%93%B1%EB%A1%9D%ED%95%98%EA%B8%B0
https://hyodev.wordpress.com/2017/03/07/%EC%9A%B0%EB%B6%84%ED%88%AC-systemd-%EC%84%9C%EB%B9%84%EC%8A%A4-%EB%93%B1%EB%A1%9D/
작성자 : RE팀 김연수 (yeonsuyam@gmail.com)
Leave Ubuntu systemd service 만들기 to:
Read more #ubuntu posts
Best Posts From uneedcomms
We have not curated any of uneedcomms's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.