Module: Unicorn::WorkerKiller
- Defined in:
- lib/unicorn/worker_killer/configuration.rb,
lib/unicorn/worker_killer.rb
Defined Under Namespace
Modules: MaxRequests, Oom Classes: Configuration
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
- .configure {|configuration| ... } ⇒ Object
-
.kill_self(logger, start_time) ⇒ Object
Kill the current process by telling it to send signals to itself.
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
7 8 9 |
# File 'lib/unicorn/worker_killer.rb', line 7 def configuration @configuration end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
108 109 110 111 |
# File 'lib/unicorn/worker_killer.rb', line 108 def self.configure self.configuration ||= Configuration.new yield(configuration) if block_given? end |
.kill_self(logger, start_time) ⇒ Object
Kill the current process by telling it to send signals to itself. If the process isn’t killed after ‘configuration.max_quit` QUIT signals, send TERM signals until `configuration.max_term`. Finally, send a KILL signal. A single signal is sent per request.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/unicorn/worker_killer.rb', line 15 def self.kill_self(logger, start_time) alive_sec = (Time.now - start_time).round worker_pid = Process.pid @@kill_attempts ||= 0 @@kill_attempts += 1 sig = :QUIT sig = :TERM if @@kill_attempts > configuration.max_quit sig = :KILL if @@kill_attempts > configuration.max_term logger.warn "#{self} send SIG#{sig} (pid: #{worker_pid}) alive: #{alive_sec} sec (trial #{@@kill_attempts})" Process.kill sig, worker_pid end |