Skip to content

Instantly share code, notes, and snippets.

@dylansmith
Created February 27, 2015 17:00
Show Gist options
  • Save dylansmith/1618ae42a0df53da3ac4 to your computer and use it in GitHub Desktop.
Save dylansmith/1618ae42a0df53da3ac4 to your computer and use it in GitHub Desktop.
Run nodemon and gulp serve together in a single command
#!/bin/bash
PIDFILE="nodemon.pid"
SERVER_PATH="server/index.js"
CLIENT_TASK="gulp serve"
if [ ! -f $PIDFILE ]; then
nohup nodemon $SERVER_PATH >/dev/null 2>&1 &
PID=$!
echo $PID > $PIDFILE
echo "nodemon running as pid $PID"
$CLIENT_TASK
rm $PIDFILE
else
PID=`cat $PIDFILE`
echo "nodemon already running as pid $PID"
fi
@dylansmith
Copy link
Author

This is useful for running a node backend and a client-side app (using something like BrowserSync) from a single command. You can point npm start at this bash script and happy days. Killing the task with ctrl-c will terminate the nodemon process as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment