私はspawn-fcgiを使用してPythonアプリを生成しています。私が下で走ればそれはうまくいきます。
spawn-fcgi -d /home/ubuntu/workspace/rtbopsConfig/rtbPixelServer/ -f /home/ubuntu/workspace/rtbopsConfig/rtbPixelServer/index.py -a 127.0.0.1 -p 9001
ここで、デーモンを作成して、開始と停止を行い、monitを使用してプロセスを監視できるようにします。私は初心者の新興ユーザーですが、以下はpixelServer.confという名前の/ etc/initに配置したファイルです。ファイルに対してchmod+xを実行しました。
#!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
以下を実行すると、シェルから以下のエラーが発生します。
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"))
では...upstartファイルを修正するにはどうすればよいですか?spawn-fcgiはsudoとして実行されるのが好きではないことを私は知っています。