[systemd-devel] GuessMainPID=no required to make daemon reload work
Gerd v. Egidy
lists at egidy.de
Mon May 5 01:00:50 PDT 2014
Hi Кирилл,
> OK, I've just re-read your message and it looks like all you need is add
> `PIDFile` to your unit.
This was the first thing I tried when writing the service file. Unfortunately it
does not work, the service is declared dead and the new daemon is killed
(unless I switch off killing, but then the state is still wrong and I can't
stop the process in a sane way).
> systemd will behave as expected: once your main process terminates it will
> re-read PID
> from this file (assuming that before dying your old process writes its
> child's PID) and set it as MAINPID for your service.
Hmm. Currently it is done like this: the old daemon releases the lock on the
pidfile and terminates itself. The new daemon detects this and then writes it's
own pid to the pidfile and locks it.
So there is a short time where the old daemon is already dead and the new one
hasn't written it's pid yet. Probably this is the problem. But I have to think
about a way to get the locking stuff right as I can't easily transfer the lock
over an exec.
> But again, if your daemon is not writing a pidfile now, this way is not
> “without changing the daemon itself first”.
The current daemon already writes a pidfile. And to be more precise, it is not
a problem to change the daemon, but I'd prefer not to introduce systemd-
specific code or dependencies (like sd_notify) in the first step.
Kind regards,
Gerd
More information about the systemd-devel
mailing list