0
description "Node app"
author "me"

start on runlevel [2345]
stop on runlevel [06]

pre-start script
        exec logger "pre-start NODEJS-CHAT app"
end script

post-start script
        exec logger "post-start NODEJS-chat app"
end script

script
        exec logger "we are launching the NODEJS-CHAT app"
        cd /var/www/html/nodejs-chat
        exec sudo -u deploybot NODE_ENV=production /usr/local/bin/node /var/www/html/nodejs-chat/server.js >> /var/www/html/nodejs-chat/log/app.log 2>&1
end script

I'm running Centos 6.5 and upstart 0.6.5 (latest available through yum). The task above can be started by manually issuing the sudo -u ... command, but it won't launch on reboot or doesn't really execute when running start nodechat. The logging command works.

Any idea what can be wrong here?

solsol
  • 1,121
  • 8
  • 21
  • 31
  • 2
    Save yourself a lot of trouble and don't bother. Native upstart scripts are not very well supported in CentOS, and it's going to be replaced by systemd in the next major version anyway. You may as well just write a standard SysV-style init script. – Michael Hampton Mar 23 '14 at 16:39
  • Thanks Michael. From what I read, upstart seems to be the go-to way to automatically run node.js apps these days. Would you suggest another way? – solsol Mar 23 '14 at 16:44
  • If you're running Ubuntu, then upstart is the way to go for now. Canonical _wrote_ upstart, after all. But even they are abandoning it in favor of systemd. So it will go away... – Michael Hampton Mar 23 '14 at 16:45
  • Sorry, I'm talking about CentOS not ubuntu. Should I skip upstart altogether? I'm looking for a way to start a node app as a daemon, especially on reboot. Would you suggest creating init.d scripts for that? upstart looked really easy to use. – solsol Mar 23 '14 at 17:04
  • See my very first comment. – Michael Hampton Mar 23 '14 at 17:05
  • Thanks, can I mark your comment as an answer? – solsol Mar 23 '14 at 17:07
  • It's not really an answer, is it? Someone might yet come along and post a solution. – Michael Hampton Mar 23 '14 at 17:08

0 Answers0