I am using spawn-fcgi to spawn a python app. If I run below it works.
spawn-fcgi -d /home/ubuntu/workspace/rtbopsConfig/rtbPixelServer/ -f /home/ubuntu/workspace/rtbopsConfig/rtbPixelServer/index.py -a 127.0.0.1 -p 9001
Now I want to create a daemon so it cna start and stop and I can use monit to monitor the proccess. I am a newbie upstart user but below is my file that I placed in /etc/init called pixelServer.conf. I did a chmod +x on the file.
#!upstart
description "pixel server"
author "Test"
start on startup
stop on shutdown
script
export HOME="/root"
echo $$ > /var/run/pixelServer.pid
exec spawn-fcgi -d /home/ubuntu/workspace/rtbopsConfig/rtbPixelServer/ -f /home/ubuntu/workspace/rtbopsConfig/rtbPixelServer/index.py -a 127.0.0.1 -p 9001 >> /var/log/pixelServer.sys.log 2>&1
#spawn-fcgi -d /home/ubuntu/workspace/rtbopsConfig/rtbPixelServer/ -f /home/ubuntu/workspace/rtbopsConfig/rtbPixelServer/index.py -a 127.0.0.1 -p 9001
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/pixelServer.sys.log
end script
pre-stop script
rm /var/run/pixelServer.pid
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/pixelServer.sys.log
end script
from the shell when I run the below, I get below error:
start pixelServer
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.66" (uid=1000 pid=29176 comm="start pixelServer ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))
So...how to I fix the upstart file? I know that spawn-fcgi does not like to be run as sudo.