Skip to content

Instantly share code, notes, and snippets.

@colegatron
Last active May 31, 2018 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colegatron/5032c68a59e2ff929894824326907e17 to your computer and use it in GitHub Desktop.
Save colegatron/5032c68a59e2ff929894824326907e17 to your computer and use it in GitHub Desktop.
Run node app as a service forwarding logs to local syslog. Can also be remote syslog using logger -n
# This is one of those little treasures hidden in the filesystem
# you always forget how you did it and which server you have it running on
# so, here it is
#
description "node web-a5-app"
start on (net-device-up and local-filesystems and runlevel [2345])
stop on runlevel [!2345]
respawn
script
[ -p /var/run/web-a5-out ] && rm /var/run/web-a5-out
[ -p /var/run/web-a5-err ] && rm /var/run/web-a5-err
mkfifo /var/run/web-a5-out
mkfifo /var/run/web-a5-err
( logger -t web-a5-out < /var/run/web-a5-out & )
( logger -t web-a5-err < /var/run/web-a5-err & )
exec >/var/run/web-a5-out
exec 2>/var/run/web-a5-err
cd /var/website
exec /home/ubuntu/.nvm/versions/node/v8.11.1/bin/node /var/website/server.js 6100
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment