If we turn this off, is it possible for systemd to send nginx the reload signal
as opposed to a complete restart?

Of course. If you look the attached service file, you can notice that the reload is fully operational. Here is a proof.

# Ensure that nginx is stopped first
root@complexe:~# systemctl stop nginx.service
root@complexe:~# pgrep nginx

# Start nginx and show actual PIDs
root@complexe:~# systemctl start nginx.service
root@complexe:~# systemctl status nginx.service
nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/etc/systemd/system/nginx.service; enabled)
[…]
 Main PID: 12876 (nginx)
   CGroup: name=systemd:/system/nginx.service
├─12876 nginx: master process /usr/sbin/nginx -g daemon off; master_process on;
           ├─12877 nginx: worker process
           ├─12878 nginx: worker process
           ├─12879 nginx: worker process
           └─12880 nginx: worker process

# Try with the reload command. Notice how worker PIDs change.
root@complexe:~# nginx -s reload
root@complexe:~# systemctl status nginx.service
nginx.service - A high performance web server and a reverse proxy server
[…]
 Main PID: 12876 (nginx)
   CGroup: name=systemd:/system/nginx.service
├─12876 nginx: master process /usr/sbin/nginx -g daemon off; master_process on;
           ├─12883 nginx: worker process
           ├─12884 nginx: worker process
           ├─12885 nginx: worker process
           └─12886 nginx: worker process

# Trying with systemctl. Notice how worker PIDs change also.
root@complexe:~# systemctl reload nginx.service
root@complexe:~# systemctl status nginx.service
nginx.service - A high performance web server and a reverse proxy server
[…]
 Main PID: 12876 (nginx)
   CGroup: name=systemd:/system/nginx.service
├─12876 nginx: master process /usr/sbin/nginx -g daemon off; master_process on;
           ├─12892 nginx: worker process
           ├─12893 nginx: worker process
           ├─12894 nginx: worker process
           └─12895 nginx: worker process

This is working because nginx writes its PID file anyway. Which is nice.


This would also break the nginx upgrade mechanism which is used for
package updates (postinst script) in order to upgrade the nginx binary
without dropping connections.

Using the current approach systemd understands that the pid has changed
correctly, probably by monitoring the pid file and the upgrade behaves
as expected. Actually there is a patch that will be included in the next
release that fixes this behaviour. [1]


Indeed, I've made some checks, that confirm a part of this. Type=forking can be removed, but PIDFile must be there, otherwise systemd thinks that since the main process is gone, the whole service should stop. With PIDFile, systemd reload the main PID from the file, and kill every other process if this main PID doesn't exist.

So to use nginx special ability to upgrade on-the-fly, at least PIDFile must be used. This would be great if the same PIDFile mentionned in the nginx's conf is used, but I don't actually see how this could be done.

And in this case, I don't have any special argument to remove the Type=forking directive, except that "it's simpler". Not so convincing ;)


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to