[systemd-devel] Systemd API for process management

Lennart Poettering lennart at poettering.net
Mon Mar 17 07:35:59 PDT 2014


On Mon, 17.03.14 10:51, Vetoshkin Nikita (nikita.vetoshkin at gmail.com) wrote:

Heya,

first things first: you really should use the dbus api for these kinds
of things, scripting around systemctl is not going to be fun...

> * Read process status - systemctl lacks robot readable output of process
> status.

"systemctl show foobar.service" should provide somewhat reasonably
parsable output for this.

> * Reap process status:
>   * there is "systemctl reset-failed" - but it reaps all failed units

It also operates on specific units, just speficy them on the command
line. If you specify none then it will reap all.

>   * services exited with 0 exit code are gone completely (maybe it's not an
> issue)

Use RemainAfterExit=yes (i.e. systemd-run -r). 

I'd be open to adding a tool to systemctl that reads the exit status
from a service that failed ot that is in RemainAfterExit= status and
writes it in a single line to stderr (unless suppressed with -q) and
then make systemctl exit with this same error code. This could then be
used to basically "join" the background service back into the foreground
control flow with its exit status.

> * Read container (cgroup) resource usage - it is possible to do that
> manually, but I think it could be great to have an API.

Yes, we definitely should have an API for this, but I am a bit afraid
how this would have to look, since we probably want history and a lot of
other stuff for the measurements we can read from cgroupfs. For now the
best way to do this is to go directly to cgroupfs and read it from
there.

> * Start processes in --user systemd instance
>   When I call systemd-run --user env I get "Failed to create message:
> Input/output error", digging with strace shows that dbus starts service
> "/usr/share/dbus-1/services/org.freedesktop.systemd1.service" which
> has Exec=/bin/false inside. I'm using Fedora 20 with systemd-211 directly
> from koji.

The --user hookup is not complete yet. This will be completed along with
the kdbus work.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list