1

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!

2
  • Anything in /var/log/messages? Do you get an error when you run daemon node /usr/local/www/server.js ? Jun 30, 2011 at 15:34
  • nothing special in /var/log/messages and daemon node /usr/local/www/server.js just executes, but no node.js processes are even started.
    – jerluc
    Jun 30, 2011 at 18:13

2 Answers 2

0

The script that you adapted is written for Red Hat-based. The trantional SysV init script on Debian-based using start-stop-daemon instead of daemon in start() function. Ubuntu 11.04 is using Upstart. Take a look at this for example.

0

Probably a silly question, but did you remove the /var/lock/subsys/node and /var/run/node.pid before trying to start the service?

You must log in to answer this question.

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