LoginSignup
5
1

More than 5 years have passed since last update.

hubotをデーモン化するだけならsystemdだけでよかった

Last updated at Posted at 2018-06-10

この前の記事で、hubotでforeverから立ち上げたんですけど、
「それsingleプロセスで立ち上げるならRestart=alwaysにするだけでいいよ」とのコメントを頂いたのでやってみました。

結論から言うと /etc/systemd/system/ に .service ファイルを作ればいいです。( .serviceファイルをユニットというみたいです)

前回の記事で書いたのと同様、上記の場所に適当に .service ファイルを作りましょう。

[Unit]
Description=Hubot 

[Service]
Type = simple
Restart=always
WorkingDirectory=/root/hubot/
ExecStart=sh bin/hubot
ExecStop=/bin/kill $MAINPID
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
systemctl start hogehoge
systemctl status hogehoge
systemctl restart hogehoge
systemctl stop hogehoge

めっちゃ簡単ですね(๑•̀ㅂ•́)و✧

書式についてはこちらが参考になりそうです。
- Systemd入門(4) - serviceタイプUnitの設定ファイル - めもめも
- Systemd メモ書き - Qiita

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1