-
-
Save base10/68297 to your computer and use it in GitHub Desktop.
Revisions
-
ntalbott revised this gist
Feb 20, 2009 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/usr/bin/env ruby command = '/usr/bin/passenger-memory-stats' memory_limit = 200 # megabytes def running?(pid) @@ -24,4 +24,4 @@ def running?(pid) Process.kill("TERM", pid.to_i) end end end -
ntalbott renamed this gist
Feb 20, 2009 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
wmoxam created this gist
Dec 30, 2008 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ #!/usr/bin/env ruby command = '/opt/ruby-enterprise-1.8.6-20080810/bin/passenger-memory-stats' memory_limit = 200 # megabytes def running?(pid) begin return Process.getpgid(pid) != -1 rescue Errno::ESRCH return false end end `#{command}`.each_line do |line| next unless /(\d+)\s+\d+\s+(\d+\.\d+)\s+MB\s+(\d+\.\d+)\s+MB\s+Rails:/.match(line) all, pid, vm_size, private = $~.to_a if private.to_i > memory_limit puts "#{Time.now}: Killing #{pid}, memory usage == #{private}" Process.kill("SIGUSR1", pid.to_i) puts "Finished kill attempt. Sleeping for 20 seconds..." sleep 20 if running?(pid.to_i) puts "Process is still running, sending term signal" Process.kill("TERM", pid.to_i) end end end