Op vr 23 nov. 2018 om 10:55 schreef Christos Trochalakis <ctrochala...@debian.org>: > >What about ExecStartPre? > > It's already at `ExecStartPre=` [0], the problem is that in `systemd > restart nginx` ExecStartPre is executed **after** the service is > stopped, not in the start of the sequence.
In that case, does it make sense to use ExecStartPre after all? Just trying to start nginx would be simpler. > [0] $ systemctl cat nginx.service|grep ^ExecStartPre= > > > >> ExecStartPre=, ExecStartPost= > > > >> Additional commands that are executed before or after the command in > >> ExecStart=, respectively. Syntax is the same as for ExecStart=, except > >> that multiple command lines are allowed and the commands are executed one > >> after the other, serially. > > > >> If any of those commands (not prefixed with "-") fail, the rest are not > >> executed and the unit is considered failed. > >> > >> >Perhaps even better, but I'm not sure if systemd and nginx supports > >> >this, would be for the new instance to be fully started before the old > >> >one is stopped. > >> > > >> > >> This can be done (in both sysvinit & systemd) systems by running > >> `/etc/init.d/nginx upgrade` but in your case a binary upgrade is not > >> needed, just a config reload (nginx -s reload). > > > >Could "service nginx restart" use this same logic? > >Users and packages probably don't know about nginx upgrade and will be > >using the standard interfaces... > > No, service restart just calls systemctl restart on systemd systems. > I think that both nginx restart & upgrade are commands that are rarely > needed in my experience: `service nginx reload` is what you usually need > and luckily that works as expected on both systemd & sysvinit. Makes sense. -- Olaf