Skip to content

Instantly share code, notes, and snippets.

@badslug
Created November 21, 2012 04:28
Show Gist options
  • Save badslug/4123022 to your computer and use it in GitHub Desktop.
Save badslug/4123022 to your computer and use it in GitHub Desktop.
Node.js Upstart config file running as an unprivileged user
description "node.js server"
author "Wyndham Jade - http://www.wyndhamjade.com"
# used to be: start on startup
# until we found some mounts weren't ready yet while booting:
start on started mountall
stop on shutdown
# Automatically Respawn:
respawn
respawn limit 99 5
# chroot won't work unless node itself is placed within the chroot (to load node core libraries)
#chroot /etc/nodeserver
script
# Not sure why $HOME is needed, but we found that it is:
export HOME="/home/nodeserver"
export PORT=8001
export MONGO_URL="mongodb://user:domain.mongolab.com:33307/user"
su -s /bin/sh -c 'exec "$0" "$@"' nodeserver -- /usr/local/bin/node /home/nodeserver/server.js >> /var/log/node-nodeserver.log 2>&1
end script
post-start script
# Optionally put a script here that will notifiy you node has (re)started
# /root/bin/hoptoad.sh "node.js has started!"
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment