Tenho esse trabalho:
# Stop dance for nginx
# =======================
#
# ExecStop sends SIGSTOP (graceful stop) to the nginx process.
# If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control
# and sends SIGTERM (fast shutdown) to the main process.
# After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends
# SIGKILL to all the remaining processes in the process group (KillMode=mixed).
#
# nginx signals reference doc:
# http://nginx.org/en/docs/control.html
#
[Unit]
Description=A high performance web server and a reverse proxy server
After=muli-user.target
Requires=network-online.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid
TimeoutStopSec=5
KillMode=mixed
[Install]
WantedBy=multi-user.target
na seção Unit
, adicionei o seguinte:
[Unit]
# ...
After=muli-user.target
Requires=network-online.target
/lib/systemd/system/nginx.service
Eu também corri o seguinte no bash:
$ sudo systemctl enable nginx
e depois para garantir que o link simbólico apareça:
$ ls -la /etc/systemd/system/multi-user.target/wants
...
lrwxrwxrwx 1 root root 33 May 14 2016 nginx.service -> /lib/systemd/system/nginx.service
...
e depois recarregue os daemons:
$ sudo systemctl daemon-reload
e finalmente reboot e veja se está lá:
$ sudo systemctl status --state active | grep nginx