You are not logged in.

#1 2019-04-30 22:47:52

marcoc
Member
Registered: 2012-02-20
Posts: 6

nginx exits on systemd reload if configuration has errors

From a a valid nginx configuration I purposedly make the configuration file invalid deleting a semicolon at the end of a line in

/etc/nginx/nginx.conf

If I try to reload from the command line, the reload is refused

# /usr/bin/nginx -s reload
2019/05/01 00:16:51 [emerg] 5180#5180: invalid number of arguments in "user" directive in /etc/nginx/nginx.conf:2

If I ask systemd to do the reload, nginx exits

# systemctl reload nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

journalctl confirms the reload failure and the exit.

systemd[1]: Reloading A high performance web server and a reverse proxy server.
systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
nginx[5185]: 2019/05/01 00:17:07 [emerg] 5185#5185: invalid number of arguments in "user" directive in /etc/nginx/nginx.conf:2
systemd[1]: nginx.service: Failed with result 'exit-code'.
systemd[1]: Reload failed for A high performance web server and a reverse proxy server.

IMHO systemd should simply refuse to reload instead of killing the running process, since the unit file contains the directive

ExecReload=/usr/bin/nginx -s reload

Is it a bug?

Offline

#2 2019-04-30 23:08:15

loqs
Member
Registered: 2014-03-06
Posts: 17,370

Re: nginx exits on systemd reload if configuration has errors

Offline

Board footer

Powered by FluxBB