[systemd-devel] Quick ? about ExecStartPre and Restart
Reindl Harald
h.reindl at thelounge.net
Wed Jul 3 16:51:31 PDT 2013
Am 04.07.2013 01:45, schrieb Paul D. DeRocco:
>> 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 has no 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
so make *two* services while the first replaces ExecStartPre
and it's "ExecStartPost=/usr/bin/systemctl start service2.service"
"but I want the service to be restarted on success" is generally
very uncommon and you can hardly have two commands in a single
service with the opposite behavior
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130704/755a9681/attachment.pgp>
More information about the systemd-devel
mailing list