systemd: Is it wrong?

Michal Schmidt mschmidt at redhat.com
Mon Jul 11 12:11:07 UTC 2011


On 07/11/2011 01:08 PM, JB wrote:
> Michal Schmidt<mschmidt<at>  redhat.com>  writes:
>> First, sub-service-1.service and sub-service-2.service will be started
>> in parallel. When they're running, main-service-1.service will be
>> started by processing its ExecStart* commands sequentially.
>> ...
>
> OK.
> Q: The sub-service-1.service and sub-service-2.service will be run as stand-
>     alone processes (of whatever kind they are: daemon, master/slave,
>     multithreaded),

Yes.

>     with no back references or dependecies of any kind
>     (parent-child like, shared resources, etc) to main-service-1.service ?

There is no parent-child relationship between services. The parent of 
all services is systemd (PID 1). Services do not spawn other services 
directly. Only systemd spawns services.

About "dependencies of any kind": In the example there are requirement 
and ordering dependencies between main-service-1.service and the 
sub-services (that's what Requires= and After= directives specify). 
systemd maintains the graph of these dependencies in its data structures.

> 2.
> main-service-2.service:
> [Unit]
> Description=Main service 2
> After= ...
> ...
> [Service]
> Type=forking<---------------------- any other type too ?
> ExecStartPre= exec /etc/init.d/sub-service-1
> ExecStartPre= exec /etc/init.d/sub-service-2
> ExecStart= /usr/sbin/some-service
> ExecStartPost=
> ExecStartPost=
> ...
>
> Would the above be correct setup-wise ?

Synchronous starting of other services may lead to deadlocks in some 
cases (e.g. https://bugzilla.redhat.com/show_bug.cgi?id=690177).
But even if you avoid the deadlock, this unit file is still horrible. 
Using systemd's dependency mechanisms (Requires, Wants, After, ...) is 
definitely cleaner.

> Are there any restrictions on those Pre (and Post) commands ?

One limitation was already mentioned somewhere in this thread - these 
commands must not fork off daemons.

>> Parallelism in systemd happens between multiple units, but never between
>> ExecStart* commands of one unit.
>> Requesting parallelism within one unit seems like over-engineering to
>> me. You can always split your unit to smaller ones if you want
>> parallelism.
>
> But this is what Steve, I believe, wants to do with nfs (to have a bunch of
> services started from the main one, as under current SysV init system, so his
> users are not confused by the startup of all these individual service files).

I proposed a way to do this cleanly using systemd targets elsewhere in 
this discussion.

>> Take a look at 'systemd-analyze plot' where you can clearly see
>> services starting in parallel.
>
> Well, I wish I could (I am on F15) ...
>
> $ systemd-analyze plot
> <?xml version="1.0" encoding="UTF-8"?>
[...]

Store it to an SVG file and then view it.

Michal


More information about the devel mailing list