I'm trying to use upstart so that the pydoc webserver for a package I'm developing always runs. If I run it from the command line:
pydoc -p 7464 /some_path/my_python_packageit works fine, and going to localhost:7464/my_python_package displays the documentation. However if I put it in an upstart script, e.g.
start on startup
start on runlevel [2,3,4,5]
stop on runlevel [0,1,6]
script pydoc -p 7464 /some_path/my_python_package
end scriptthen when I open up the browser at localhost:7464/my_python_package I get the following:
no Python documentation found for 'my_python_package' Note that localhost:7464 shows all of the standard python packages as normal, so it seems like upstart isn't parsing the path correctly.
I tried using putting export PYTHONPATH='/some_path' in and changing the execution line to pydoc -p 7464 $PYTHONPATH/my_python_package but this didn't work either.
1 Answer
The syntax you've specified in that job is incorrect:
- you have multiple '
start on' stanzas. - the last '
start on' stanza will be considered, but yours is invalid due to using commas between runlevels (your 'stop on' is invalid for the same reason).
You want something like this:
start on runlevel [2345]
stop on runlevel [016]
script pydoc -p 7464 /some_path/my_python_package
end scriptNote that with version 0.9.7 and higher of Upstart (in other words Ubuntu Natty or newer - see ), there is a new command called init-checkconf that will check your script for syntax errors. Usage is simple:
$ init-checkconf myjob.confNote that you must run init-checkconf as your user (not root).
Also, are you running this as a system job (job file lives in /etc/init/ ?) If so, do you really need the service to run as root? If not, see:
if this is a do you really need to run that service as the root user?
Finally, I would highly recommend taking a look at the rest of the Upstart Cookbook:
- HTML version:
- PDF version: