-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RGRB を systemd で制御するためのサービスファイルと、そのドキュメントを追加した。 また、追加したドキュメントへのリンクを README.md に追記した。
- Loading branch information
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[Unit] | ||
Description=RGRB - Internet Relay Chat bot | ||
Documentation=http://www.cre.ne.jp/services/irc/bots/rgrb | ||
After=network.target | ||
|
||
[Service] | ||
User=irc | ||
Group=irc | ||
Type=simple | ||
PIDFile=/home/irc/rgrb/rgrb.pid | ||
WorkingDirectory=/home/irc/rgrb | ||
ExecStart=/home/irc/rgrb/bin/rgrb-ircbot -c config/rgrb.yaml | ||
#ExecReload=/usr/bin/kill -HUP $MAINPID | ||
ExecStop=/usr/bin/kill $MAINPID | ||
Restart=always | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[Unit] | ||
Description=RGRB - Internet Relay Chat bot | ||
Documentation=http://www.cre.ne.jp/services/irc/bots/rgrb | ||
After=network.target | ||
|
||
[Service] | ||
User=irc | ||
Group=irc | ||
Type=simple | ||
PIDFile=/home/irc/rgrb/%I.pid | ||
WorkingDirectory=/home/irc/rgrb | ||
ExecStart=/home/irc/rgrb/bin/rgrb-ircbot -c config/%I.yaml | ||
#ExecReload=/usr/bin/kill -HUP $MAINPID | ||
ExecStop=/usr/bin/kill $MAINPID | ||
Restart=always | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
systemd 用サービスファイル | ||
========================== | ||
|
||
ファイル目次 | ||
------------ | ||
|
||
* rgrb.service | ||
通常のサービスファイルです。 | ||
* rgrb@.service | ||
テンプレートサービスファイルです。 | ||
|
||
使い方 | ||
------ | ||
|
||
以下の項目を前提としてサービスファイルを作成しています。 | ||
|
||
* RGRB を専用ユーザー"irc"のホームディレクトリにインストールする | ||
* 専用ユーザーの権限で実行する | ||
* 何らかの要因で終了した場合、自動的に再起動する | ||
|
||
各システムの定められた場所に、上記のサービスファイルをコピーします。 | ||
例えば CentOS7 では、`/etc/systemd/system` です。 | ||
|
||
### サービスファイルに指定する設定値 | ||
|
||
1つの RGRB を運用するだけでしたら、通常のサービスファイルで十分でしょう。 | ||
通常のサービスファイル (rgrb.service) を上記ディレクトリにコピーします。 | ||
|
||
お使いのシステムにあわせて *[Service]* 内にある各項目の設定値を書き換えます。 | ||
|
||
| 項目名 | 設定値 | | ||
| ------ | ------ | | ||
|User|プロセスの実行ユーザー| | ||
|Group|プロセスの実行グループ| | ||
|PIDFile|プロセスの PID を保存するファイル| | ||
|WorkingDirectory|RGRB のルートディレクトリ| | ||
|ExecStart|フルパスで RGRB の起動ファイルとオプション| | ||
|ExecReload|現在、RGRB はリロードに対応していないためコメントアウト| | ||
|ExecStop|終了するためのコマンド| | ||
|Restart|*always* を設定すると自動再起動有効| | ||
|
||
*ExecXXXX* に指定するコマンドは、すべてフルパスで記述します。 | ||
RGRB に与えるオプションのうち、設定ファイルは *WorkingDirectory* からの相対パスを利用することができます。 | ||
|
||
複数の RGRB の設定ファイルを用意し、同時並行で利用する場合でしたら、テンプレートサービスファイルを使うことをお勧めします。 | ||
テンプレートサービスファイルを利用する場合、```systemctl``` コマンドに与えるサービス名が、*<サービス名>@<識別名>* という書式になります。 | ||
テンプレートサービスファイル内では、設定値内の *%I* がサービス起動時に与える *<識別名>* に置換されてコマンドが実行されます。 | ||
デフォルト設定では、 ```config/``` ディレクトリ以下に置いた設定ファイルの(拡張子を除いた)ファイル名が *<識別名>* になるように書かれています。 | ||
|
||
参考文献 | ||
-------- | ||
|
||
1. [Linux女子部 systemd徹底入門](http://www.slideshare.net/enakai/linux-27872553) | ||
1. [systemd.exec](http://www.freedesktop.org/software/systemd/man/systemd.exec.html) |