I am trying to run Google AppEngine on my Debian machine, I created a file init.d/gae
:
. /lib/lsb/init-functions
#
# Initialize variables
#
name=gae
user=$name
pid=/var/run/$name.pid
prog="python /opt/google_appengine/dev_appserver.py --host=0.0.0.0 --admin_host=0.0.0.0 --php_executable_path=/usr/bin/php-cgi /var/www"
case "${1}" in
start)
echo "Starting...Google App Engine"
start-stop-daemon --start --make-pidfile --background --oknodo --user "$user" --name "$name" --pidfile "$pid" --startas "$prog"
;;
stop)
echo "Stopping...Google App Engine"
;;
restart)
${0} stop
sleep 1
${0} start
;;
*)
echo "Usage: ${0} {start|stop|restart}"
exit 1
;;
esac
exit 0
# End scriptname
I am testing the script by manually invoking, and the script runs but not as a daemon or at least it doesn't detach from terminal. I am expecting/looking for similar functionality to Apache.
What switch am I missing?
EDIT
I should note that no PID file is being written or created despite the switch indicating it should be created
Best Answer
You have two problems I can see:
Will start
/opt/google_appengine/dev_appserver.py
withprog=python
in the environment. This is before yourstart
block, sostart-stop-daemon
isn't even getting involved.The quick fix is to quote the entire assignment like this:
But a better fix is to use the style from
/etc/init.d/skeleton
, and doThe second problem is that you're wrongly quoting
$prog
.tells
start-stop-daemon
to try to start a program calledpython /opt/google_appengine/dev_appserver.py --host=0.0.0.0 --admin_host=0.0.0.0 --php_executable_path=/usr/bin/php-cgi /var/www
.But clearly there is no program called that. You want to start
python
with arguments. Removing the double quotes there is the quick fix, but a better one, again following/etc/init.d/skeleton
, would be