nginx/nginx.service
Jamie Nguyen 0f695d477b Remove PID file before starting nginx (#1268621)
`nginx -t` creates the file /run/nginx.pid if it doesn't exist. `nginx -t` is
executed by ExecStartPre (in nginx.service) and creates /run/nginx.pid with the
correct SELinux context. However, when manually running `nginx -t` from the
cmdline, the SELinux transition for systemd services doesn't occur and
/run/nginx.pid is created with the wrong SELinux context. A workaround is to
make sure that the PID file is removed before starting nginx.
2015-10-04 08:32:14 +01:00

22 lines
616 B
Desktop File

[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=mixed
PrivateTmp=true
[Install]
WantedBy=multi-user.target