[systemd-devel] Service not restarting after Condition failed

Umut Tezduyar Lindskog umut at tezduyar.com
Sun Nov 30 00:13:44 PST 2014


On Tue, Nov 25, 2014 at 2:38 PM, D.S. Ljungmark <spider at aanstoot.se> wrote:
> On 24/11/14 20:30, Umut Tezduyar Lindskog wrote:
>> Hi
>>
>> On Monday, November 24, 2014, D.S. Ljungmark <spider at aanstoot.se
>> <mailto:spider at aanstoot.se>> wrote:
>>
>>     On 10/11/14 23:09, Lennart Poettering wrote:
>>     > On Thu, 30.10.14 18:47, D.S. Ljungmark (spider at aanstoot.se
>>     <javascript:;>) wrote:
>>     >
>>     >> Hi
>>     >>  we have a service set to:
>>     >> ConditionFileNotEmpty=
>>     >>
>>     >> and
>>     >>
>>     >> Restart=Always
>>     >>
>>     >>
>>     >> This combination would (in my feebled mind) cause the service to
>>     restart
>>     >> once the Condition was fulfilled, but that doesn't seem to be the
>>     >> case.
>>     >
>>     > Conditions are something that are on-time evaluated right before we
>>     > would start a unit, and cause this starting to be shortcut. That's all
>>     > really. Restarts are only triggered when a running service dies, and
>>     > the start job queued by that will then check the conditions again. If
>>     > the condition doesn't hold then this start will not be executed, and
>>     > hence no restart ever again either...
>>     >
>>     >> Is there a way I can get a service to restart even after it has
>>     been set
>>     >> as inactive (dead) "start condition failed"?
>>     >
>>     > Nope, conditions are not for that. For the specific check of
>>     > file-not-empty there's no nice way to handle this, however for
>>     > directory-not-empty you could set up DirectoryNotEmpty=...
>>     >
>>     >> Should I simply remove the Condition, or something else?
>>     >
>>     > What precisely are you trying to do?
>>     >
>>     > Lennart
>>
>>     Basically, some files (config & certificates) may not exist on a system
>>     until it's provisioned properly, something that may take a while ( a few
>>     days)
>>
>>     After provisioning, we want the services depending on those file to
>>     start automatically.
>>
>>
>> Path unit files should work for
>> you,  http://www.freedesktop.org/software/systemd/man/systemd.path.html
>>
>> Umut
>
> Thanks, those would work well. I take it those should be in combination
> to the ConditionFileNotEmpty=  for the same files?

I believe you need to use ConditionFileNotEmpty=. Did it work out for you?

Umut

>
>
>
> //D.S.
>
>
> --
> 8362 CB14 98AD 11EF CEB6  FA81 FCC3 7674 449E 3CFC
>


More information about the systemd-devel mailing list