[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Ensure service keeps running with systemd



Michael Biebl <biebl@debian.org> writes:

> Am 28.10.2016 um 00:50 schrieb Tobias Brink:
>> Hello!
>>
>> tl;dr: When a daemon exits "normally" (for example due to signal 15)
>>        although it should not exit (because I did not call "systemctl
>>        stop"), systemd does not consider it a failure.
>
> [..]
>
>> How do I tell systemd that it is a failure if the daemon is not running,
>> except if I explicitly killed it via "systemctl stop" or similar? I
>> either can't seem to find the right google query or this is not the
>> right way to go about this.
>
> There is also Restart=always
>
> See
> https://www.freedesktop.org/software/systemd/man/systemd.service.html#Restart=

Whoops, that part should have been obvious. Thanks.

> and
> https://www.freedesktop.org/software/systemd/man/systemd.service.html#SuccessExitStatus=

I'm not sure if this helps. According to the documentation, an exit code
of 0 and termination by unhandled SIGHUP, SIGINT, SIGTERM, and SIGPIPE
is always treated as a successful exit. Assigning the empty string only
seems to reset it to this default. Apart from that, fetchmail may also
return "1" during a successful shutdown. If I don't add that, systemd
will complain during "systemctl stop" that shutdown of the daemon was
not clean. This is not what I want.

So, Restart=always works, but I still can't get systemd to notify me if
the service is restarted after exiting with a code of "0". The solution
may be to send a notification every time the service starts, but I want
to avoid being notified every time the computer is rebooted or if I
restart the service manually.

Thanks,

Tobias


Reply to: