3 # Get a list of rack processes that are running
4 pgrep -u rails -f Rack | sort > /tmp/rails.actual.$$
6 # Get a list of rack processes we expect to be running
7 passenger-status | awk '/PID:/ { print $3 }' | sort > /tmp/rails.expected.$$
9 # Get a list of unexpected rack processes
10 pids=$(comm -23 /tmp/rails.actual.$$ /tmp/rails.expected.$$)
12 # Kill any expected rack processes
13 [ -n "$pids" ] && kill -9 $pids
15 # Remove our temporary files
16 rm -f /tmp/rails.actual.$$ /tmp/rails.expected.$$