Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

This is my Node.JS webserver startup script for RedHat EL 6.

#!/bin/sh
# chkconfig:   345 01 01
# description: DeepFlow startup script

case $1 in
        start)
            echo "Starting DeepFlow"
            cd /home/admin/Desktop/DeepFlow/server
            ./bin/node js/server.js
            ;;
        stop)
            echo "Stopping DeepFlow"
            killall node
            ;;
esac

For some reason, when I manually type

            cd /home/admin/Desktop/DeepFlow/server
            ./bin/node js/server.js

everything works fine, but when I do service DeepFlow start I get a Node.JS error:

Starting DeepFlow

events.js:71
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: failed to connect to [localhost:27017]

What is the difference between manually typing the script lines in a terminal, and running the script with service?

share|improve this question
up vote -1 down vote accepted

Try using full pathnames.

NODE_BIN="/home/admin/Desktop/DeepFlow/server/bin/node"
SERVER_JS="/home/admin/Desktop/DeepFlow/server/js/server.js"
echo "Starting DeepFlow"
$NODE_BIN $SERVER_JS
;;

Also it would be good to check which user is starting the server. If it's run on startup, the owner will be 'root'.

share|improve this answer
    
Nope, didn't work. – Randomblue Feb 18 '13 at 10:00
    
Do you have some library path in your env-variables? Maybe using export NODE_PATH="/home/admin/Desktop/DeepFlow/server/" would help. – Kride Feb 18 '13 at 10:32

You must log in to answer this question.

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