Troubleshooting upstart jobs

October 2010


Debugging upstart is documented. And for general usage, there's the Upstart CookBook. Just want to add here that sourcing files from the script... ...end script section seems to not work. And if you 're putting the actual script in /usr/share/<packagename>/script anyway, you might as well do:

#!/bin/bash

some-routine()
{
echo "This is the start of my routine"
echo "and now my routine has ended."
}

some-routine|tee >(logger -t "my-routine from myjob.conf"
    

which will give you output in both the logs and on the screen.

[Note]Note

Using Bash here has the advantage of being able to direct the stdout of tee to logger, which I don't know how to do in the default Dash.

It is possible to specify that a job must start as soon as its preliminaries are available. It will then start as soon as possible, e.g.

start on local-filesystems
    

Its is also possible to specify that a job must start before some other job. Init will then make sure that the other job doesn't get started before this one finishes, e.g.

start on starting kdm
    

It is however not possible (as far as I know) to specify that a job should start before some other job and wait for preliminaries. All I could think of was to do this in a set of two jobs: one that starts the work as soon as possible, and another that waits for the results (and thereby delays the job before which the results should be available).