Need help with systemd service files

Juerg Haefliger juergh at gmail.com
Fri Feb 24 12:22:18 UTC 2012


2012/2/23 Michal Schmidt <mschmidt at redhat.com>:
> On 02/23/2012 03:35 PM, Juerg Haefliger wrote:
>>
>> All services have an [install] section, I just dropped them for this
>> email. Forgot to pull in C.target where? Should D.service contain
>> "After=rc-local.service C.target" then?
>
>
> By "pull in" I mean making it included in the transaction. Ordering
> dependencies (such as After) have no effect on that. Only requirement
> dependencies can pull units into the transaction. Units that are not in the
> transaction cannot influence the ordering of the transaction.
> So you need to add "Wants=C.target" somewhere.

Hmm... So I fail to see the difference between After and Wants then.
What's the difference between ordering and requirement dependencies?

I added 'Wants' to each service/target file, listing the same services
as on the 'After' lines. Seems to be working now.


>> Rerun using 'systemctl restart' would be nice. So 'RemainAfterExit=y'
>> needs to stay, right?
>
>
> The 'restart' action will work the same in both cases.
> It's the 'start' action where the difference can be seen. 'start' won't do
> anything if the service is already active.
> The 'restart' action first makes the unit stop (thus making sure it is
> inactive) and then start.
>
>
>>> Do you want the admin to be able to enable/disable each service
>>> separately?
>>
>>
>> The A-D services don't need to be managed separately, it's either all
>> of them or none.
>
>
> In that case adding Wants makes sense.
>
> May I know what package is this exactly? It's possible we may have missed
> something important by talking in the abstract A,B,C,D terms.

Oh sure, it's not a secret. It's cloud-init and I used abstract names
for clarity. I just realized that a Fedora package exists already.
Duh! At least I learned some Fedora packaging :-)
So I installed the official Fedora version of cloud-init but the
service startup ordering is broken there too:

[root at 342 ~]# dmesg | grep cloud | grep About
[   91.668396] systemd[1]: About to execute: /usr/bin/cloud-init start-local
[   91.993238] systemd[1]: About to execute: /usr/bin/cloud-init-cfg all config
[   92.540255] systemd[1]: About to execute: /usr/bin/cloud-init-cfg all final
[   92.559834] systemd[1]: About to execute: /usr/bin/cloud-init start


The correct order should be:
systemd[1]: About to execute: /usr/bin/cloud-init start-local
systemd[1]: About to execute: /usr/bin/cloud-init start
systemd[1]: About to execute: /usr/bin/cloud-init-cfg all config
systemd[1]: About to execute: /usr/bin/cloud-init-cfg all final


Thanks for your help
...Juerg


> Michal


More information about the devel mailing list