Skip to content

Instantly share code, notes, and snippets.

@rahul100885
Created February 11, 2011 05:08
Show Gist options
  • Save rahul100885/821956 to your computer and use it in GitHub Desktop.
Save rahul100885/821956 to your computer and use it in GitHub Desktop.
This script will kill a rails instance which is taking more than 500 MB and retsrat a request if it has served 100 requests
#!/bin/sh
while true; do
passenger-memory-stats | grep Rails:\ /home | awk ' { if($2 > 500) print "kill -9 " $1}' | bash
# above line will kill all the rails instances which are using memory more than 500MB
passenger-status | grep Processed: | awk ' { if($7 > 100) print "kill -6 " $3}' | bash
# above line will abort all rails instance who have processed 100 request.
sleep 2
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment