[systemd-devel] Quick ? about ExecStartPre and Restart
Paul D. DeRocco
pderocco at ix.netcom.com
Wed Jul 3 16:45:49 PDT 2013
> From: Reindl Harald [mailto:h.reindl at thelounge.net]
>
> Am 04.07.2013 00:38, schrieb Paul D. DeRocco:
> > I'm new to systemd, and I'm confused about something. The
> > docs include the
> > following sentence under the Restart directive:
> >
> > "Configures whether the service shall be restarted when the
> > service process
> > exits, is killed, or a timeout is reached. The service
> > process may be the
> > main service process, but also one of the processes specified with
> > ExecStartPre=, ExecStartPost=, ExecStopPre=, ExecStopPost=,
> > or ExecReload=."
> >
> > Read literally, this suggests that if I set this to "on-success" or
> > "always", and I have an ExecStartPre that runs a quick
> > command (in my case,
> > to copy my main service executable from a flash drive to a
> > RAM drive), then
> > as soon as that completes, systemd will say, "Hey, the service has
> > terminated, time to restart it" and never get around to the
> > ExecStart that
> > really does the work.
> >
> > Is that really true? Or is that just a mistake in the docs?
> > If it's not a
> > mistake, how do I configure it so that it won't restart
> > when the command
> > launched by ExecStartPre terminates with a 0 exit code, but
> > will restart if
> > the actual service started by ExecStart terminates with a 0
> > exit code?
>
> it is not true and the documentation ha sno mistake
>
> systemd does *not* consider the service as failed if ExecStartPre
> terminates with a clean 0 exit code - it is considered as failed
> if the ExecStartPre command does return a *non zero* code and
> even that can be avoided with ExecStartPre=-/path/to/bin as the
> doc states
I understand that, but I want the service to be restarted on success, not on
failure. By that I mean that if my ExecStart process (the actual service)
ever terminates with a 0 exit code, I want the whole thing to restart,
beginning with the ExecStartPre. But I DON'T want the 0 exit code from
ExecStartPre to restart anything, because that's not the actual service.
--
Ciao, Paul D. DeRocco
Paul mailto:pderocco at ix.netcom.com
More information about the systemd-devel
mailing list