Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

# Node Server Startup

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

exit 0

Thanks for any help!

share|improve this question

migrated from Jun 30 '11 at 15:21

This question came from our site for professional and enthusiast programmers.

Anything in /var/log/messages? Do you get an error when you run daemon node /usr/local/www/server.js ? – Bart De Vos Jun 30 '11 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 '11 at 18:13

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.

share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.