I only see some warnings like conflicting server name ignored when I use systemctl restart not systemctl reload. I keep reloading and there’s no error so it’s misleading you think it’s fine. Can I see warnings in the output or log when I reload?
Hi there,
“systemctl” is not an nginx command, so there is not much that nginx can do about it directly.
What systemctl does (effectively) is run the commands that are configured in the matching “service” file. You can probably most easily see what they are by running
systemctl cat nginx | grep ^Exec
You can stop or reload a running nginx directly by invoking the appropriate “nginx -s” command as described at Beginner’s Guide or you can use an external tool like “kill” to send the appropriate signal to the appropriate process id, as described at Controlling nginx .
By observation: “kill -HUP $(cat logs/nginx.pid)” returns silently, while “sbin/nginx -s reload” shows the desired warnings on stderr before returning. Both do cause the warnings to be written to the error_log, and both do cause the “master” nginx pid to remain unchanged while the “worker” nginx pids will be new. “ps -ef | grep [n]ginx” can show you those, before and after the reload.
(Strictly: you will want to include whatever “-c config-file” argument was provided to the original nginx invocation, in order for “nginx -s” to identify the correct pidfile to read.)
“systemctl reload” runs its configured “ExecReload” command, and (presumably?) shows the matching stderr output.
So if your nginx.service file uses something like “kill” to reload, then you could maybe try changing it to do something like “nginx -s reload” and see if that shows you what you want?
Alternatively – always read the error.log after a reload.
Good luck with it,