Systemd service life cycle

Colin Law clanlaw at gmail.com
Thu Apr 7 08:31:42 UTC 2016


On 7 April 2016 at 09:17, Ralf Mardorf <silver.bullet at zoho.com> wrote:
> On Thu, 7 Apr 2016 08:43:47 +0100, Colin Law wrote:
>>This leads me to think that A is defined as Started once ExecStart has
>>been called, but only guarantees that the script has been initiated,
>>not that it has actually accomplished anything.
>
> Systemd is known for race conditions. I would let a wrapper B check
> against A being ready.

Thanks Ralf, could you explain exactly what you mean by that?  Do you
mean I should just make B hang until the tunnel is up?  In fact I
don't really want to do anything special in B at all if I can manage
it, as it is a standard service (openHAB) and if I hack the .service
file it may get overwritten if openHAB is upgraded.

I wonder whether I could put the wait in ExecStartPost, but that would
only work if the service is not marked as Started until after
ExecStartPost returns.  There must be an answer to this problem, I am
sure I am not the first to come across this issue.

>
>>If I am correct then I think I should put the tunnel setup in
>>ExecStartPre.
>
> "Note that ExecStartPre= may not be used to start long-running
> processes. All processes forked off by processes invoked via
> ExecStartPre= will be killed before the next service process is run." -
> https://www.freedesktop.org/software/systemd/man/systemd.service.html

Hmm, yes you are right, so I can't set up the tunnel in Pre.

Colin




More information about the ubuntu-users mailing list