D-Bus Service Activation through Upstart

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

D-Bus Service Activation through Upstart

Scott James Remnant-2
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

--
ubuntu-devel mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel
Reply | Threaded
Open this post in threaded view
|

Re: D-Bus Service Activation through Upstart

Zygmunt Krynicki-4
W dniu 22.12.2010 19:03, Scott James Remnant pisze:

> 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

Could upstart by any chance reuse the Exec line from the .service file.
It seems that repeating this is a DRY violation that makes no practical
sense. I realize that it makes upstart's job harder (need to track and
parse another file but from administrator's point of view it makes lots
of sense).

Best regards
ZK

--
ubuntu-devel mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel
Reply | Threaded
Open this post in threaded view
|

Re: D-Bus Service Activation through Upstart

Scott James Remnant-2
In reply to this post by Scott James Remnant-2
On 22/12/10 18:03, Scott James Remnant wrote:

> /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)
>
Small correction,

this should be UpstartJob=true to maintain conformance to the XDG
Desktop File Spec.

Scott

--
ubuntu-devel mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel