Last active
October 8, 2018 16:29
-
-
Save dylants/6133762 to your computer and use it in GitHub Desktop.
upstart config file for running node.js on a linux machine. This uses nodemon to allow file changes when pulled from git. This also specifies the NODE_ENV environment variable as "production" which would trigger the app to production mode (as opposed to development). Remove the environment variable if development environment is desired.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!upstart | |
description "nodemon server for myapp" | |
author "ubuntu" | |
start on startup | |
stop on shutdown | |
script | |
export HOME="/home/ubuntu/git/myapp" | |
echo $$ > /var/run/myapp.pid | |
cd $HOME | |
exec sudo -u ubuntu NODE_ENV=production PORT=3000 /usr/bin/nodemon app.js >> /var/log/myapp.sys.log 2>&1 | |
end script | |
pre-start script | |
# Date format same as (new Date()).toISOString() for consistency | |
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/myapp.sys.log | |
end script | |
pre-stop script | |
rm /var/run/myapp.pid | |
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/myapp.sys.log | |
end script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://howtonode.org/deploying-node-upstart-monit
Location: /etc/init/myapp.conf
Start/Stop:
sudo service myapp start
sudo service myapp stop
Logs:
/var/log/myapp.sys.log