Prestart DBus services
David Zeuthen
zeuthen at gmail.com
Mon Aug 1 14:14:50 PDT 2011
On Mon, Aug 1, 2011 at 5:01 PM, Michael Rasmussen <mir at datanom.net> wrote:
> Hi all,
>
> In lastest releases of DBus your are able to instruct upstart to
> prestart DBus services under boot, but what do you do when upstart is
> not available? Can you instruct DBus to start the service synchronous?
>
> Using upstart
> [D-BUS Service]
> Name=org.some.DbusService
> Exec=/usr/bin/DbusService
> User=foo
> UpstartJob=true
>
> The reason for my question is that I have a service which takes a few
> seconds to populate some internal data structure and when a client
> requests service for the first time the function is called before the
> data structure is populated and therefore returns an empty list.
>
> I could of course wait in the function for the list to populate but
> what if this wait time is longer than the hardcoded timeout in DBus?
You can use the dbus-send(1) command (or gdbus(1) or own custom code
or whatever) to invoke the StartServiceByName() method, see,
http://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-messages
to activate the service at boot time. Example:
# dbus-send --system --dest=org.freedesktop.DBus --print-reply
/org/freedesktop/DBus org.freedesktop.DBus.StartServiceByName
string:org.freedesktop.UDisks uint32:0
IIRC systemd has a way to encode this in a config file too.
David
More information about the dbus
mailing list