[systemd-devel] dbus user services using the session bus
Tom Gundersen
teg at jklm.no
Wed Apr 3 09:27:23 PDT 2013
On Wed, Apr 3, 2013 at 3:22 PM, Will Stephenson <wstephenson at kde.org> wrote:
> I'm joining the flock of desktop people investigating using systemd to start
> a desktop session. So far I've checked out user-session-units and have
> created some more granular unit files that will do a native systemd start
> rather than u-s-u's wrapper around the upstream start script.
Is your code available somewhere?
> I'm stuck now, because I want to start a service with Type=dbus that puts a
> service on the session bus, however, I can't see a way to specify the bus in
> the unit file.
When using Type=dbus with "systemd --user" the session bus is used
(assuming I understand everything correctly, and there are no bugs).
> I don't want to use dbus activation here to start the service as that
> invokes the chicken-egg problem that the service in question (kdeinit) job
> is to start all the processes that will be calling it via dbus later. Long
> term I would like to do away with this and perform this task via systemd
> too, but Type=dbus on the session bus seems like a valid use case that
> should work.
Well, you could (and maybe should) enable dbus activation even though
you need to start your service also in case it does not get dbus
activated. That way you won't need to worry about ordering kdeinit
before things that may connect to it over dbus. See e.g. avahi for a
service that works like this:
# systemctl enable avahi-daemon
ln -s '/usr/lib/systemd/system/avahi-daemon.service'
'/etc/systemd/system/dbus-org.freedesktop.Avahi.service'
ln -s '/usr/lib/systemd/system/avahi-daemon.service'
'/etc/systemd/system/multi-user.target.wants/avahi-daemon.service'
ln -s '/usr/lib/systemd/system/avahi-daemon.socket'
'/etc/systemd/system/sockets.target.wants/avahi-daemon.socket'
> I see there's a way to get the dbus session bus address into systemd because
> of the patch to fix this in user-session-units; would the right approach be
> to add a BusInstance= field to service and use the provided session bus
> address when watching for Type=dbus services that depend on
> user/dbus.service?
Are you sure this doesn't JustWork the way you need it to at the moment?
-t
More information about the systemd-devel
mailing list