hubotをデーモン化するだけならsystemdだけでよかった
この前の記事で、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
Author And Source
この問題について(hubotをデーモン化するだけならsystemdだけでよかった), 我々は、より多くの情報をここで見つけました https://qiita.com/fruitriin/items/22f4075e2c9cf100d385著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .