home ホーム search 検索 -  login ログイン  | reload edit datainfo version cmd icon diff delete  | help ヘルプ

技術/Linux/systemd/graceful shutdown or config reload 参考メモ (v1)

技術/Linux/systemd/graceful shutdown or config reload 参考メモ (v1)

技術 / Linux / systemd / graceful shutdown or config reload 参考メモ (v1)
id: 1376 所有者: msakamoto-sf    作成日: 2017-02-06 15:59:22
カテゴリ: Apache Linux systemd 

systemdにてgraceful shutdown or graceful reload などを行うための参考メモ。

CentOS7でのApacheの例:

→ /usr/lib/systemd/system/httpd.service:

[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true

[Install]
WantedBy=multi-user.target

ポイント:

  1. graceful reloadコマンドは ExecReload 指定になったため、systemctl reload httpd で呼べるようになっている。
  2. デフォルトでは systemctl stop で一気にSIGTERMが送信されてしまうので、それを避けるため、KillSignal=SIGCONT で無害なシグナルを送信するように修正している。代わりに ExecStop ではSIGWINCHを送るようにしており、これは apachectl -k graceful-stop と同等らしい。

systemd本家manページ:

RedHat のユニットファイルの解説:

その他参考:



プレーンテキスト形式でダウンロード
現在のバージョン : 1
更新者: msakamoto-sf
更新日: 2017-02-06 16:10:46
md5:a58ca241b707cbb86bb75e00e96690fe
sha1:09ef53e8ecb37e36a2bc31e544b7a569e293932a
コメント
コメントを投稿するにはログインして下さい。