I am using upstart to create a daemon for a spawned nginx python fastcgi script. If I use the below it works:
sudo start myserver
What does not work is:
sudo stop myserver
stop: Unknown instance:
Below is my conf file with the command for stopping the process. I am assuming that the command for killing hte proccess is in pre-stop script?
#!upstart
description "myserver"
author "Test"
start on startup
stop on shutdown
respawn
#instance
script
export HOME="/root"
echo $$ > /var/run/myerver.pid
exec spawn-fcgi -d /home/ubuntu/workspace/rtbopsConfig/myserver/ -f /home/ubuntu/workspace/rtbopsConfig/myserver/index.py -a 127.0.0.1 -p 9001 >> /var/log/myserver.sys.log 2>&1
end script
pre-start script
# Date format same as (new Date()).toISOString() for consistency
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/myserver.sys.log
end script
pre-stop script
rm /var/run/myserver.pid
sudo kill `sudo lsof -t -i:9001`
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/myserver.sys.log
end script