Re: Need help with systemd service files

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

 



Hi Michal,

>
> Hello,
>
>
> On 02/23/2012 01:34 PM, Juerg Haefliger wrote:
>>
>> Any of the services could fail but that shouldn't affect any of
>> the other services.
>
>
> From this you can deduce the answer to one of your questions.
> You don't want to use Requires then.

Ok.


>> 1) Service A after the local filesystem is mounted.
>> 2) Service B after the network is up and service A terminated.
>> 3) At this point I'd like to create a reference point for other services
>> to hook into.
>> 4) Service C after the reference point and after syslog is up.
>> 5) Service D after rc-local and after service C terminated.
>>
>> What I have at the moment is the following:
>>
>> A.service:
>> [unit]
>> Description=A
>> After=local-fs.target
>
>
> You don't need to state this ordering dependency, because your service
> will get the default dependency on basic.target which implies
> local-fs.target indirectly.

Ok.


>> [Service]
>> Type=oneshot
>> ExecStart=/usr/bin/A
>> RemainAfterExit=yes
>>
>> B.service:
>> [unit]
>> Description=B
>> After=network.target A.service
>> [Service]
>> Type=oneshot
>> ExecStart=/usr/bin/B
>> RemainAfterExit=yes
>>
>> C.target:
>> [unit]
>> Description=C
>> After=A.service B.service
>>
>> C.service:
>> [unit]
>> Description=C
>> After=syslog.target C.target
>
> syslog.target is always available these days, because the syslog socket gets activated early.

Ok.


>> [Service]
>> Type=oneshot
>> ExecStart=/usr/bin/C
>> RemainAfterExit=yes
>>
>> D.service:
>> [unit]
>> Description=D
>> After=rc-local.service C.service
>> [Service]
>> Type=oneshot
>> ExecStart=/usr/bin/D
>> RemainAfterExit=yes
>
>
> I don't see any [Install] sections, so I assume you simply linked the services manually into multi-user.target.wants.
> Apparently you forgot to pull in C.target as well, so you fail to get the ordering the target was supposed to ensure.

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?


>> Do I really need 'RemainAfterExit=y'?
>
>
> It depends. Do you want the services to appear as "active(exited)" or "inactive(dead)" after they've run? Do you want "systemctl start A.service" to be a no-op after boot, or should it re-run the program again?

Rerun using 'systemctl restart' would be nice. So 'RemainAfterExit=y'
needs to stay, right?


>> Do I need any 'Wants' or 'Requires'?
>
>
> You don't want Requires, as mentioned above.
> Whether you want Wants... again, it depends. Does it make sense to start the services without trying to start the ones that you said should be ordered before?

Not sure I understand. The sequence needs to be as described above
#1-#5, e.g. D should not start until A-C are done.


> 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.


Thanks for your help
...Juerg



>
> Michal
-- 
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/devel



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux