I am trying to run Google AppEngine on my Debian machine, I created a file init.d/gae:

. /lib/lsb/init-functions

# Initialize variables


prog="python /opt/google_appengine/dev_appserver.py --host= --admin_host= --php_executable_path=/usr/bin/php-cgi /var/www"

case "${1}" in
      echo "Starting...Google App Engine"
      start-stop-daemon --start --make-pidfile --background --oknodo --user "$user" --name "$name" --pidfile "$pid" --startas "$prog" 


      echo "Stopping...Google App Engine"


      ${0} stop
      sleep 1
      ${0} start

      echo "Usage: ${0} {start|stop|restart}"
      exit 1

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?


I should note that no PID file is being written or created despite the switch indicating it should be created

  • Does User gae have opermission to write to /var/run?
    – eyoung100
    Commented Sep 9, 2014 at 23:39
  • You don't have a #! definition defined. I think that will cause an issue. What do you want this to run as? bash, sh, ksh? Putting a #!/bin/bash will tell the system which shell to run this as.
    – Warwick
    Commented Sep 9, 2014 at 23:40
  • 2
    The prog=python /opt/google_appengine/dev_appserver.py... line is missing quotes, causing it to get started there, not inside the start-stop-daemon code.
    – Mikel
    Commented Sep 10, 2014 at 2:41
  • It's not related to your answer : your script is not standard, add LSB header to head of your script. Commented Sep 10, 2014 at 4:17
  • 1
    Where is python located and is that in the PATH when the init.d files are started.
    – Anthon
    Commented Sep 10, 2014 at 5:47

2 Answers 2


You have two problems I can see:

prog=python /opt/google_appengine/dev_appserver.py --host= --admin_host= --php_executable_path=/usr/bin/php-cgi /var/www

Will start /opt/google_appengine/dev_appserver.py with prog=python in the environment. This is before your start block, so start-stop-daemon isn't even getting involved.

The quick fix is to quote the entire assignment like this:

prog='python /opt/google_appengine/dev_appserver.py --host= --admin_host= --php_executable_path=/usr/bin/php-cgi /var/www'

But a better fix is to use the style from /etc/init.d/skeleton, and do

DAEMON='python /opt/google/appengine/dev_appserver.py'
DAEMON_ARGS='--host= --admin_host= --php_executable_path=/usr/bin/php-cgi /var/www'

The second problem is that you're wrongly quoting $prog.

start-stop-daemon --start --make-pidfile --background --oknodo --user "$user" --name "$name" --pidfile "$pid" --startas "$prog"

tells start-stop-daemon to try to start a program called python /opt/google_appengine/dev_appserver.py --host= --admin_host= --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

start-stop-daemon --start --quiet --chuid $CHUID --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS

  • Damn, was just about to post this :-). Your final command though is missing --background, --make-pidfile, and --oknodo. Any particular reason?
    – phemmer
    Commented Sep 11, 2014 at 2:39
  • Well, I identified the problem 23 hours ago, so figured I might as well get the points. ;)
    – Mikel
    Commented Sep 11, 2014 at 2:49
  • I was just copying the flags from the skeleton file. You're right that in this case it looks like --background and friends can be re-added.
    – Mikel
    Commented Sep 11, 2014 at 2:51
  • I did end up quoting the prog value (I edited original post) and that didn't work. If it was the double quotes causing this issue...I will carp my pants -- late though so I will test first thing tomorrow. Commented Sep 11, 2014 at 3:12
  • DAEMON_ARGS made all the difference...jeepers crepes...thank you so much...I tried so many combinations...an entire day troubleshooting python, start-stop-daemon, etc...and the solution was a simple syntactical fix...man I can't thank you enough :) Commented Sep 11, 2014 at 3:37

For the life of me I could not figure out why start-stop-daemon was not working...I am running Debian 7.6 wheezy and I can only assume the feature has been disabled.

I change the like to use /dev/null and the & and voila -- sciprt starts and stays running as expected...I stole the code from mysql:

$prog > /dev/null 2>&1 &

I would be very interested if someone could explain why this works and the original solution does not...in anycase I figured I would share my experience in hopes of:

  1. Saving someone else the headache of mucking around with the solution
  2. Prompting someone to step up and explain how to get this working as I originally wanted :)

EDIT | Here are the two lines of interest now

prog='/usr/bin/python /opt/google_appengine/dev_appserver.py --host= --admin_host= --php_executable_path=/usr/bin/php-cgi /var/www'

start-stop-daemon --start --make-pidfile --background --oknodo --user $user --name $name --pidfile $pid --exec $prog
  • I think it's because you removed the quotes from "$prog". Remove the >/dev/null 2>&1 & part and see what happens.
    – Mikel
    Commented Sep 11, 2014 at 2:53
  • OK I edited the answer I provided with the changes I made and now i'm getting an error (start-stop-daemon: unrecognized option '--host=' Commented Sep 11, 2014 at 3:24
  • 1
    You need the -- like in $DAEMON -- $DAEMON_ARGS.
    – Mikel
    Commented Sep 11, 2014 at 3:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .