]> git.openstreetmap.org Git - chef.git/blob - cookbooks/web/templates/default/passenger.cron.erb
Ignore errors killing processes which may have already exited
[chef.git] / cookbooks / web / templates / default / passenger.cron.erb
1 #!/bin/sh
2
3 # Get a list of rack processes that are running
4 pgrep -u rails -f Rack | sort > /tmp/rails.actual.$$
5
6 # Get a list of rack processes we expect to be running
7 passenger-status | awk '/PID:/ { print $3 }' | sort > /tmp/rails.expected.$$
8
9 # Get a list of unexpected rack processes
10 pids=$(comm -23 /tmp/rails.actual.$$ /tmp/rails.expected.$$)
11
12 # Kill any expected rack processes
13 [ -n "$pids" ] && kill -9 $pids > /dev/null 2>&1
14
15 # Remove our temporary files
16 rm -f /tmp/rails.actual.$$ /tmp/rails.expected.$$