Created
November 25, 2009 14:18
-
-
Save ThisIsMissEm/242732 to your computer and use it in GitHub Desktop.
A very basic daemon for Node.js
This file contains 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/sh | |
CUR_DIR=$PWD | |
PID_FILE="$CUR_DIR/node.pid" | |
if [ $1 = "start" ]; then | |
if [ -e $PID_FILE ]; then | |
echo "Node.js is already running." | |
else | |
echo "Starting Node Server" | |
(node $2 &) > /dev/null && ps -C node | cut -d" | |
" -f 2 | cut -d" " -f 1 > $PID_FILE | |
fi | |
elif [ $1 = "stop" ]; then | |
if [ ! -e $PID_FILE ]; then | |
echo "Node.js is not running." | |
else | |
echo "Stopping Node Server" | |
kill `cat $PID_FILE` | |
rm -rf $PID_FILE | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment