Skip to content

Instantly share code, notes, and snippets.

@jwreagor
Forked from ThisIsMissEm/gist:242732
Created March 30, 2010 15:17
Show Gist options
  • Save jwreagor/349186 to your computer and use it in GitHub Desktop.
Save jwreagor/349186 to your computer and use it in GitHub Desktop.
#! /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