Skip to content

Instantly share code, notes, and snippets.

@lee
Created December 5, 2011 19:46
Show Gist options
  • Select an option

  • Save lee/1435031 to your computer and use it in GitHub Desktop.

Select an option

Save lee/1435031 to your computer and use it in GitHub Desktop.
Monitor unicorn for memory usage
-- 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