Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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!

share|improve this question

migrated from stackoverflow.com 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

2 Answers 2

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/node.pid before trying to start the service?

share|improve this answer

Your Answer

 
discard

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.