Skip to content

Commit

Permalink
Merge pull request #17 from jclem/master
Browse files Browse the repository at this point in the history
Do not require configuration, fix missing randomize method in MaxRequests
  • Loading branch information
kzk committed Mar 9, 2013
2 parents 8abb582 + 725d601 commit eb093d4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/unicorn/worker_killer.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require 'unicorn/configuration'

module Unicorn::WorkerKiller
class << self
attr_accessor :configuration
end

# Self-destruction by sending the signals to myself. The process sometimes
# doesn't terminate by SIGQUIT, so this tries to send SIGTERM and SIGKILL
# if it doesn't finish immediately.
Expand Down Expand Up @@ -41,11 +45,11 @@ def self.new(app, memory_limit_min = (1024**3), memory_limit_max = (2*(1024**3))
end
app # pretend to be Rack middleware since it was in the past
end

def randomize(integer)
RUBY_VERSION > "1.9" ? Random.rand(integer) : rand(integer)
end

def process_client(client)
super(client) # Unicorn::HttpServer#process_client
return if @_worker_memory_limit_min == 0 && @_worker_memory_limit_max == 0
Expand All @@ -64,6 +68,7 @@ def process_client(client)
end

private

def _worker_rss
proc_status = "/proc/#{Process.pid}/status"
if File.exists? proc_status
Expand Down Expand Up @@ -110,6 +115,10 @@ def self.new(app, max_requests_min = 3072, max_requests_max = 4096)
app # pretend to be Rack middleware since it was in the past
end

def randomize(integer)
RUBY_VERSION > "1.9" ? Random.rand(integer) : rand(integer)
end

def process_client(client)
super(client) # Unicorn::HttpServer#process_client
return if @_worker_max_requests_min == 0 && @_worker_max_requests_max == 0
Expand All @@ -129,7 +138,5 @@ def self.configure
yield(configuration) if block_given?
end

class << self
attr_accessor :configuration
end
self.configure
end

0 comments on commit eb093d4

Please sign in to comment.