On Thu, 15.11.12 10:06, Matthew Miller (mat...@fedoraproject.org) wrote:

> On Thu, Nov 15, 2012 at 01:53:32AM +0100, Lennart Poettering wrote:
> > In fact, all system bus services should be configured to defer
> > activation to systemd, so that all services regardless how they are
> > triggered are executed in the same clean execution environment, and can
> > be manipulated with the same commands (systemctl
> > stop/kill/restart/mask/...) as any other services.
> [...]
> > It's really not that hard. I think it's a really good rule to make all
> > low-level system daemons work that way, to keep things robust and
> > resource usage minimal.
> 
> I was looking for resources on systemd and dbus activation. I realized that
> the documentation here is very scarce -- there's this tutorial on just dbus
> activation <http://raphael.slinckx.net/blog/documents/dbus-tutorial> and our
> wiki page <http://fedoraproject.org/wiki/Packaging:Systemd#DBus_activation>,
> but it seems like it might make a nice "systemd for Developers", if you
> feel inspired at any point.

There's indeed not much documentation around. This is primarily because
we were kinda waiting for kernel dbus to materialize which would
probably shuffle a few things around in this area.

Here's the gist of it:

1) In /usr/share/dbus-1/system-services/*.service use the
   SystemdService= setting to declare that activation of a specific
   D-Bus service should be done with systemd.

2) Basically, that's already it. However, here's a twist: instead of
   directly specifiying the systemd service file name I recommend
   specifying the name of a symlink which point to the actual
   service, and is available only if the service is actually
   enabled. Then, add Alias= for this symlink name to [Install] in the
   unit file. This way you can now enable/disable the service and this
   affects bus activation as administrators would expect.

Here's an example for Avahi:

In /usr/share/dbus-1/system-services/org.freedesktop.Avahi.service:

    [D-BUS Service]
    Name=org.freedesktop.Avahi
    SystemdService=dbus-org.freedesktop.Avahi.service

And in /usr/lib/systemd/system/avahi-daemon.service:

    [Unit]
    Description=Avahi mDNS/DNS-SD Stack
    Requires=avahi-daemon.socket

    [Service]
    Type=dbus
    BusName=org.freedesktop.Avahi
    ExecStart=/usr/sbin/avahi-daemon -s
    ExecReload=/usr/sbin/avahi-daemon -r
    NotifyAccess=main

    [Install]
    WantedBy=multi-user.target
    Also=avahi-daemon.socket
    Alias=dbus-org.freedesktop.Avahi.service

The important line here is the last, which has the effect that the
symlink /etc/systemd/system/dbus-org.freedesktop.Avahi.service is
managed by "systemctl enable" and "systemctl disable" so that the bus
activation only works when avahi is actually enabled.

Naming the symlinks "dbus-xyz.service" (with xyz being the actual bus
name) is a just a recommendation, nothing is requiring that...

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel

Reply via email to