Upstart script doesn't start

Ubuntu 10.04

I have created this upstart script (/etc/init/pure-ftpd.conf):

# pure-ftpd - FTP server

description "Pure-FTPd server"

start on filesystem
stop on runlevel S

respawn
respawn limit 10 5
pid file /var/run/pure-ftpd.pid
console output

pre-start script
    test -x /usr/local/sbin/pure-ftpd || { stop; exit 0; }
end script

exec /usr/local/sbin/pure-ftpd --maxclientsnumber 2 --maxclientsperip 10 --prohibitdotfileswrite --prohibitdotfilesread --noanonymous --chrooteveryone --dontresolve --nochmod --pidfile /var/run/pure-ftpd.pid

But...

# start pure-ftpd
start: Unknown job: pure-ftpd

and

# service pure-ftpd start
start: Unknown job: pure-ftpd


What's the problem?
Is it necessary to do something more?
Is it necessary to create one script in /etc/init.d too?


Solution 1:

You can also run init-checkconf to check syntax

init-checkconf /etc/init/job.conf
File /etc/init/job.conf: syntax ok

Solution 2:

It usually means you have an error in the .conf file - for instance I'm not sure the pid stanza is supported in 10.04, stop can't be used in the script etc.

I'd try starting the file from scratch (with only start, stop etc), and then slowly building it up by adding more and more lines and testing it via start pure-ftpd.

For example:

# cat pure-ftpd.conf 
start on filesystem
stop on runlevel S

respawn
respawn limit 10 5

# start pure-ftpd
pure-ftpd start/running

# cat pure-ftpd.conf 
start on filesystem
stop on runlevel S

respawn
respawn limit 10 5
pid file /var/run/pure-ftpd.pid

# start pure-ftpd
start: Unknown job: pure-ftpd

Solution 3:

First, you can check that your job is actually known to upstart:

sudo initctl list | grep your_job_name

...where your_job_name is the name of your upstart script minus the .conf extension.

If it's not found, you can try reloading the configuration and then re-checking:

sudo initctl reload-configuration

# re-check
sudo initctl list | grep your_job_name

Then try again to start your job:

sudo start your_job_name

If you weren't getting any logging in /var/log/daemon.log or /var/log/syslog before, you might have some now.