Created
February 11, 2011 12:16
-
-
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
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
#!/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