[systemd-devel] Has systemd booted up command

Lennart Poettering lennart at poettering.net
Wed Sep 11 17:38:53 PDT 2013


On Thu, 18.07.13 20:36, Umut Tezduyar (umut at tezduyar.com) wrote:

Hey,

> Implementing a tool that catches the dbus signal, like you have said
> must be relatively easy. In fact I believe it should be possible to do
> it by dbus-monitor but the main problem is, tool itself must be
> started by systemd as a service with a Before={target you are booting
> to}. Otherwise you cannot be sure if the StartupFinished signal has
> been sent before the tool starts.

This won't work. If you run the tool as a service like you suggest then
this service will have a job queued as long as it is running and you
will hence never get StartupFinished since your own tool is still queued.

> The other need is coming due to an item in our TODO list which is,
> "when isolating, try to figure out a way how we implicitly can order
> all units we stop before the isolating unit...". Since the stop jobs
> are asynchronous, I would be using following command to make sure that
> isolation is fully complete: "systemctl is-active MyIsolated.target &&
> systemctl show -pNJobs | grep -q Njobs=0". I do believe, this might
> not be a common use case and I can live with parsing the output of
> "systemctl show -pNJobs".

Note that if two units are ordered against each other (regardles whether
with Before= or After=) and a stop job is queued for one of them, and a
start job is queued for the other, then the stop job will always be
executed first, the start job second. Hence it is sufficient to simply
order all units you want to have finished before or after your isolated
unit and you get what you need.

It's usually safer (and less deadlock-prone) to use systemd's own job
queuing rather than attempting your own on the side...

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list