init.d service died

Posted by jerluc on Server Fault See other posts from Server Fault or by jerluc
Published on 2011-06-30T07:37:22Z Indexed on 2011/06/30 16:24 UTC
Read the original article Hit count: 200

Filed under:
|
|
|

Adapting some code from a linux forum, I've added a service script to /etc/init.d on my ubuntu natty server to start/stop/restart node.js It literally was working the first day I made it, but then today, after viewing my website this morning, the server threw a 404, and upon further inspection, the node.js process was gone. So I went to start the service again, only this time, node.js didn't start at all, and ever since I haven't been able to get my service script working.

Below is the entire script:


#!/bin/sh
#
# Node Server Startup
#

case "$1" in
  start)
        echo -n "Starting node: "
        daemon node /usr/local/www/server.js
        echo
        touch /var/lock/subsys/node
        ;;
  stop)
        echo -n "Shutting down node: "
        killall node
        echo
        rm -f /var/lock/subsys/node
        rm -f /var/run/node.pid
        ;;
  status)
        status node
        ;;
  restart)
        $0 stop
        $0 start
        ;;
  reload)
        echo -n "Reloading node: "
        killall node -HUP
        echo
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac

exit 0

Thanks for any help!

© Server Fault or respective owner

Related posts about shell

Related posts about daemon