Ubuntu – How to start nginx via upstart

Ubuntuubuntu-10.04upstart

Background:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04 LTS"

I've built nginx, and I'd like to use upstart to start it:

nginx upstart script from the site:

description "nginx http daemon"

start on runlevel 2

stop on runlevel 0
stop on runlevel 1
stop on runlevel 6

console owner

exec /usr/sbin/nginx -c /etc/nginx/nginx.conf  -g "daemon off;"

respawn

I get "unknown job" when i try to use initctl to run it, which I just learned apparently means there is an error, ( what's wrong with "Error" to describe errors?)

Can someone point me in the right direction ? I've read the documentation , as it is, and it seems kind of sparse for a SysV init replacement… but whatever just need to add this job to the list, run it, and get on with what's left of my life… Any tips?

EDIT: initctl version
init (upstart 0.6.5)

Best Answer

You cannot have multiple stop on directives in an upstart job description for Upstart >= 0.5.

And console owner is probably not what you want (this makes nginx the owner of the system console).

Try:

description "nginx http daemon"
start on runlevel 2
stop on runlevel [016]
console output
exec /usr/sbin/nginx -c /etc/nginx/nginx.conf  -g "daemon off;"
respawn