Created
December 5, 2011 19:46
-
-
Save lee/1435031 to your computer and use it in GitHub Desktop.
Monitor unicorn for memory usage
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
| -- monitor memory usage | |
| check process unicorn_worker0 | |
| with pidfile unicorn_worker0.pid | |
| if mem > 280.0 MB for 2 cycles then exec "/bin/bash -c '/bin/kill -3 `cat unicorn_worker0.pid` && sleep 1'" | |
| -- write a worker pid in unicorns after_fork |server, worker| | |
| worker_pid = File.join(File.dirname(server.config[:pid]), "unicorn_worker#{worker.nr}.pid") | |
| File.open(worker_pid, "w") { |f| f.puts Process.pid } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment