Skip to content

Instantly share code, notes, and snippets.

@rla
Created May 13, 2012 17:23
Show Gist options
  • Save rla/2689368 to your computer and use it in GitHub Desktop.
Save rla/2689368 to your computer and use it in GitHub Desktop.
Node.JS startup scripts
start.sh:
#!/usr/bin/env bash
if [ -e 'master.pid' ]
then
echo 'Master PID file exists, cannot start.'
exit 1
fi
NODE_ENV=production /usr/local/bin/node app.js &>> server.log &
stop.sh:
#!/usr/bin/env bash
if [ -e 'master.pid' ]
then
kill `cat master.pid`
fi
init script:
#!/usr/bin/env bash
case "$1" in
'start')
su - kamweb -c 'cd /home/kamweb && ./start.sh' ;;
'stop')
su - kamweb -c 'cd /home/kamweb && ./stop.sh' ;;
*)
echo "Usage: $0 { start | stop }" ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment