upstart script (tiny)

Simple upstart script


env PORT=5001

start on runlevel [2345]
stop on runlevel [016]
respawn

setuid john
chdir /home/john/Applications/my-nodejs-server/
exec node index.js


  1. Can configure environment variables in a faux 12 factor style.
  2. NodeJS app will automatically start on boot, and stop on shutdown.
  3. Upstart will restart the app if it crashes.
  4. Runs as unpriveleged user 'john'.
  5. Upstart (1.4 and above) logs all output to /var/log/upstart/my-nodejs-server.log which will be rotated by logrotate.
  6. Can manage the lifecycle with sudo service my-nodejs-server {start,stop,restart}.
  7. Can temporarily disable the app from starting on boot with an override file: 
    $ echo manual | sudo tee /etc/init/my-nodejs-server.override.

Comments

Popular posts from this blog

Sites, Newsletters, and Blogs

Oracle JDBC ReadTimeout QueryTimeout

Locks held on Oracle for hours after sessions abnormally terminated by node failure