Skip to content

Instantly share code, notes, and snippets.

@johnl
Created June 2, 2015 12:17
Show Gist options
  • Save johnl/4c7e51b8bc20ee4bf07e to your computer and use it in GitHub Desktop.
Save johnl/4c7e51b8bc20ee4bf07e to your computer and use it in GitHub Desktop.
Hacky patch to unicorn to log process ram use after each request
class Unicorn::HttpServer
alias process_client_orig process_client
undef_method :process_client
def process_client(client)
process_client_orig(client)
rss = `ps -o rss= -p #{Process.pid}`.chomp.to_i / 1024
puts "Unicorn #{Process.pid}, #{request.env['REQUEST_METHOD']} #{request.env['REQUEST_PATH']} using #{rss}M"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment