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_INSTANCE_REGISTRY_DIR=<%= node[:passenger][:instance_registry_dir] %> 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 > /dev/null 2>&1
15 # Remove our temporary files
16 rm -f /tmp/rails.actual.$$ /tmp/rails.expected.$$