Skip to content

Instantly share code, notes, and snippets.

@rrrodrigo
Created February 11, 2011 12:16
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 rrrodrigo/822268 to your computer and use it in GitHub Desktop.
Save rrrodrigo/822268 to your computer and use it in GitHub Desktop.
an unfinished attempt at creating a Node.js init script - in the end I went with https://github.com/indexzero/forever
#!/bin/bash
if [ -f node.pid ] ; then
rm node.pid
fi
node node_script.js &
PID=$!
sleep 1
check=`ps ax | grep node | grep -v grep | grep $PID | wc -l`
if [ $check -eq 1 ] ; then
echo $PID > node.pid
echo "Node has started"
exit 0
else
echo "Node could not be started"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment