nodeapp upstart script improvements

Issue #10 new
Damon Oehlman repo owner created an issue

Some good improvements from @silviapfeiffer customizations in real usage:

  • Ability to override the node environment
  • Capture stderr to a log file also

Here's an example of the file in production:

description "rfw app"

# wait for the user-jobs signal to be emitted
start on user-jobs

# environment variables for the script
env NODE_PORT=3010
env SERVER_PORT=3010
env NODE_ENV='development'

# change into the correct directory and run the script
chdir /srv/apps/rfw/master
exec /opt/local/node/0.10.21/bin/node server.js >>../logs/access.log 2>../logs/error.log

# respawn if it dies
respawn

Comments (1)

  1. Silvia Pfeiffer

    Actually, "exec" has an issue when you're trying to redirect the output. I've decided to use the "script" directive instead:

    # wait for the user-jobs signal to be emitted
    start on user-jobs
    
    # environment variables for the script
    env NODE_PORT=3010
    env SERVER_PORT=3010
    env NODE_ENV=development
    
    # change into the correct directory and run the script
    chdir /srv/apps/rfw/master
    script
      /opt/local/node/0.10.21/bin/node server.js >>../logs/access.log 2>../logs/error.log
    end script
    
    # respawn if it dies
    respawn
    
  2. Log in to comment