Skip to content

Instantly share code, notes, and snippets.

@lstoll
Created August 23, 2011 12:40
Show Gist options
  • Save lstoll/1165000 to your computer and use it in GitHub Desktop.
Save lstoll/1165000 to your computer and use it in GitHub Desktop.
hacky way to run and mange a bunch of processes
#!/bin/bash
old_mongo_pid=`ps auxww | grep mongod | egrep -v grep | awk '{print $2}'`
# Start mongo and memcache if not running
ps aux | grep mongod | grep -v grep || mongod &
#ps aux | grep memcached | grep -v grep || memcached & pids="$pids $!"
if [ "$old_mongo_pid" == "" ]
then
echo "mongo wasnt running"
sleep 1
pids="`ps auxww | grep mongod | egrep -v grep | awk '{print $2}'` $pids"
fi
echo $pids
cd content
rackup -s thin & pids="$pids $!"
rails server thin & pids="$pids $!"
trap "echo caught signal;kill -15 $pids;sleep 1;kill $pids; exit" 1 2 3 6 15
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment