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