Class: WorkerKiller::Killer::Base
- Inherits:
-
Object
- Object
- WorkerKiller::Killer::Base
- Defined in:
- lib/worker_killer/killer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#kill_attempts ⇒ Object
Returns the value of attribute kill_attempts.
Instance Method Summary collapse
-
#do_kill(*_args) ⇒ Object
:nocov:.
-
#initialize(logger: nil, **_kwargs) ⇒ Base
constructor
A new instance of Base.
- #kill(start_time, **params) ⇒ Object
-
#logger ⇒ Object
:nocov:.
Constructor Details
#initialize(logger: nil, **_kwargs) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 |
# File 'lib/worker_killer/killer.rb', line 7 def initialize(logger: nil, **_kwargs) @logger = logger @config = WorkerKiller.configuration @kill_attempts = 0 end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
5 6 7 |
# File 'lib/worker_killer/killer.rb', line 5 def config @config end |
#kill_attempts ⇒ Object
Returns the value of attribute kill_attempts.
5 6 7 |
# File 'lib/worker_killer/killer.rb', line 5 def kill_attempts @kill_attempts end |
Instance Method Details
#do_kill(*_args) ⇒ Object
:nocov:
26 27 28 |
# File 'lib/worker_killer/killer.rb', line 26 def do_kill(*_args) raise 'Not Implemented' end |
#kill(start_time, **params) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/worker_killer/killer.rb', line 13 def kill(start_time, **params) alive_sec = (Time.now - start_time).round @kill_attempts += 1 sig = :QUIT sig = :TERM if kill_attempts > config.quit_attempts sig = :KILL if kill_attempts > (config.quit_attempts + config.term_attempts) do_kill(sig, Process.pid, alive_sec, **params) end |
#logger ⇒ Object
:nocov:
31 32 33 |
# File 'lib/worker_killer/killer.rb', line 31 def logger @logger || WorkerKiller.configuration.logger end |