0

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
James Nine
  • 173
  • 1
  • 7
  • 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 " and "stop " 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
  • It does not get filled in when I reboot, but it does get filled in when I run `sudo start firstapp` – James Nine Aug 17 '11 at 16:34
  • So then you Upstart is not installed correctly or the script doesn't get triggered. – mailq Aug 17 '11 at 16:35
  • I installed upstart via `apt-get install upstart` on debian. My guess is that upstart is still too new/unstable for debian (as of this writing, 8/17/2011) and I might just scrap it and go back to sysvinit for now, until it becomes more mature for debian in the next few years. Thanks for all your help though! – James Nine Aug 17 '11 at 16:37

1 Answers1

1

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

thomst
  • 11
  • 1