#navi_header|技術| systemdにてgraceful shutdown or graceful reload などを行うための参考メモ。 CentOS7でのApacheの例: - CentOS7 で service httpd graceful をするには -- https://blog.cles.jp/item/7392 - Systemd管理下のApacheでgracefulを使う | bacchi.me -- https://bacchi.me/linux/tips-3/ - apacheの起動,停止,再起動に関するまとめ - Qiita -- http://qiita.com/rimoenic/items/81385e08cf772ae5cfe4 → /usr/lib/systemd/system/httpd.service: #code||> [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 ||< ポイント: + graceful reloadコマンドは ExecReload 指定になったため、systemctl reload httpd で呼べるようになっている。 + デフォルトでは systemctl stop で一気にSIGTERMが送信されてしまうので、それを避けるため、KillSignal=SIGCONT で無害なシグナルを送信するように修正している。代わりに ExecStop ではSIGWINCHを送るようにしており、これは apachectl -k graceful-stop と同等らしい。 systemd本家manページ: - systemd.service -- https://www.freedesktop.org/software/systemd/man/systemd.service.html - systemd.kill -- https://www.freedesktop.org/software/systemd/man/systemd.kill.html# - systemctl -- https://www.freedesktop.org/software/systemd/man/systemctl.html# RedHat のユニットファイルの解説: - 第8章 systemd によるサービス管理 -- https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/chap-Managing_Services_with_systemd.html#tabl-Managing_Services_with_systemd-Introduction-Units-Types - 8.6. システムのユニットファイルの作成および変更 -- https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Unit_Files.html その他参考: - Linux女子部 systemd徹底入門 -- http://www.slideshare.net/enakai/linux-27872553 #navi_footer|技術|