Created
October 22, 2009 16:14
-
-
Save lackac/216060 to your computer and use it in GitHub Desktop.
A primitive way to ensure that your Passenger processes don't eat up your machine completely. It will kill any Rack app process that starts to eat more than 300MB RAM. I used this to find a leak in a Sinatra application.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while :; do | |
stats=$(passenger-memory-stats | grep Rack) | |
if [ "$stats" != "" ]; then | |
echo $stats | |
echo $stats | egrep --color=always 'MB ([12][0-9]|[3-9])..\.. MB' | |
pid=$(echo $stats | egrep 'MB ([12][0-9]|[3-9])..\.. MB' | awk '{ print $1 }') | |
if [ "$pid" != "" ]; then | |
ps aux | grep $pid | |
kill $pid && echo "$pid killed." | |
fi | |
echo "---" | |
fi | |
sleep 0.5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment