D-Bus Service Activation through Upstart
Scott James Remnant
scott at ubuntu.com
Wed Dec 22 18:03:38 UTC 2010
With the most recent upload of D-Bus (1.4.1-0ubuntu2) it is now possible
for D-Bus services to be activated via Upstart.
For example, let's say we wanted to convert the existing
com.ubuntu.LanguageSelector service over. First you need to edit the
D-Bus service file:
/usr/share/dbus-1/system-services/com.ubuntu.LanguageSelector.service
[D-BUS Service]
Name=com.ubuntu.LanguageSelector
Exec=/usr/lib/language-selector/ls-dbus-backend
User=root
+ UpstartJob=y
(I've marked the new UpstartJob=y line you need to add)
Next create an Upstart Job for it
/etc/init/LanguageSelector.conf
start on dbus-activation com.ubuntu.LanguageSelector
exec /usr/lib/language-selector/ls-dbus-backend
And you're done.
Obviously it gets much more useful when you add other Upstart features
into the mix; D-Bus activated services are just Upstart jobs, so you can
have pre-start scripts, you can have custom umasks, chroots, oom
adjustments, etc.
And you can also put more things in that "start on" line, for example to
start something on activation or some other event:
start on surprise \
or dbus-activation com.ubuntu.Example
You can use "and" here too, but be careful since that may prevent it
from being activated more than once. (It waits for both events each time).
Scott
More information about the ubuntu-devel
mailing list