0

I registered the init.d script and when I invoke this directly /etc/init.d/gae it appears to work...PID file is created but the process is no where to be seen by the time I do a ps

I have googled and best determined it is possibly a path issue, with "python" not being located properly? If I remove the "quotes" around prog variable Google AppEngine runs as expected and stays running, but it also won't detach from terminal...any ideas?

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
  • can you run ```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``` – Mike Sep 10 '14 at 16:37
  • Yes works fine but hangs the terminal. I need this run as a daemon however. – Alex.Barylski Sep 10 '14 at 17:11
  • Maybe silly, but did you try to use /usr/bin/python (or wherever it is located) in your prog string? – Klemen Sep 10 '14 at 23:28
  • I have yes...no dice... – Alex.Barylski Sep 11 '14 at 01:30
  • I don't understand why there is no instruction in the `stop` case. When you say you use `ps`, what are the options? consider using `ps aux` or `ps -ef` and pipe the result into a `grep` for readability. – Manu H Sep 11 '14 at 11:37

1 Answers1

0

You need to separate the command and its options, specifying all of those as --startas "$prog" means that start-stop-daemon will look for a command named "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", all one string without any options...

So:

prog="python"
options="/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"
...
start-stop-daemon --start --make-pidfile --background --oknodo --user "$user" --name "$name" --pidfile "$pid" --startas "$prog" -- $options

Additionally, if dev_appserver.py has execute permissions and starts with #!/usr/bin/python then make that the $prog and remove it from $options:

prog="/opt/google_appengine/dev_appserver.py"
options="--host=0.0.0.0 --admin_host=0.0.0.0 --php_executable_path=/usr/bin/php-cgi /var/www"
wurtel
  • 3,864
  • 12
  • 15