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

I have been dabbling with Node.js lately, and I came across this article on how to get it to start automatically after a reboot:

http://howtonode.org/deploying-node-upstart-monit

In particular, the article recommends that I use upstart (I'm running Debian Squeeze). I've been able to install upstart fine, and when I use the "start" and "stop" commands, everything works perfect. However, whenever I reboot, Node.js never runs. The log is empty and I can't figure out why it's not working. I'm ready to give up on upstart, but I want to know if anyone else is having the same issue?

Here is my upstart script:

description "node.js server"
author      "me"

start on (local-filesystems and net-device-up IFACE=eth0) 
# i also tried "start on startup", still does not work.
stop on shutdown

respawn
respawn limit 5 60

script
exec sudo -u node sh -c "/usr/local/bin/node /opt/apps/firstapp/app.js >> /var/log/firstapp.log 2>&1"
end script
share|improve this question
    
Hmm. I was not aware that squeeze uses Upstart?! Can you confirm that Upstart is really used after your install? Have you configured sudo to execute sh without prompting for a password/passphrase? –  mailq Aug 17 '11 at 15:24
    
Yes, apparently you can install upstart on squeeze (you do get a warning though), but since I'm new to upstart, most of the guides I've read have said to confirm that it is working, you merely have to type the commands "start <programname>" and "stop <programname>" to confirm it's working--both of which worked on my end. And yes, I have configured sudo to execute sh without prompting for a password. –  James Nine Aug 17 '11 at 16:06
    
So what is in the (existing?) firstapp.log? –  mailq Aug 17 '11 at 16:08
    
the firstapp.log file is blank. And yes, the user "node" has full permissions to write to the file. –  James Nine Aug 17 '11 at 16:26
    
change the 2nd last line to exec echo "Executed" >> /var/log/firstapp.log 2>&1. Does it get filled then? –  mailq Aug 17 '11 at 16:31
show 3 more comments

1 Answer

try to use filesystem instead of local-filesystems. Possibly /usr/local is NOT ready mounted on local-filesystems. (I had a similar issue once)

share|improve this answer
add comment

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.