[systemd-devel] Question about After/Before of services

WANG Chao wangchao19890207 at gmail.com
Thu Aug 9 21:32:30 PDT 2012


On 08/09/2012 05:56 PM, Zbigniew Jędrzejewski-Szmek wrote:
> On 08/09/2012 10:04 AM, WANG Chao wrote:
>> On 08/09/2012 01:59 PM, Zbigniew Jędrzejewski-Szmek wrote:
>>> On 08/09/2012 06:28 AM, WANG Chao wrote:
>>>> Hi, list
>>>>
>>>> As you see in the subject, this question comes from a lazy guy like me,
>>>> who doesn't read the systemd source code at all :P
>>> Hey, no need to read the source code :). Please see the man page:
>>> http://www.freedesktop.org/software/systemd/man/systemd.unit.html
>>>
>>> Zbyszek
>>>
>> Hi,
>>
>> Trust me, I've read that section hundreds of times. I'm actually not
>> that lazy ;)
>>
>> I come up with this confusion when I configure a service A 'wants' and
>> 'after' B. I thought they should be started one by one in a exact order,
>> but actually they intersected and run in parallel.
> So: A after B, A wants B, means that when A is started, B will be
> started first, and after B is started, A will be started second.
> So the startup phase is sequential, but later on run in parallel.
>
It matches what I saw. Make sense.

> Reading your post again, I think you might have something like startup
> scripts in mind, where the first should finish _running_ and exit before
> the second one starts. You can achieve this by adding
>    Type = oneshot

How could I miss this :(

> to the first service (or even to both of them).
>
> You also say "right after": sorry, can't help you here. There's no way
> to ensure that the system will not do some work in between.
>

Sorry, when I said "right after", I didn't mean "right" after.. Just 
after is fine.

Thanks for your help, I really appreciate it! I learn a lot :)

> Zbyszek
>
>>>>
>>>> The silly question is if A is configured to 'Wants:B' and 'After:B',
>>>> will A start exactly after B is finished or after B is started?
>>>>
>>>> If A is started after B is started (still parallel somehow), is there
>>>> anything I can do to control A to be started right after B is done?


-- 
Thanks,
WANG Chao


More information about the systemd-devel mailing list