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 12 |
# File 'lib/worker_killer/killer.rb', line 7 def initialize(logger: nil, **_kwargs) @logger = logger @config = WorkerKiller.configuration @kill_attempts = 0 @sig = nil 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:
32 33 34 |
# File 'lib/worker_killer/killer.rb', line 32 def do_kill(*_args) raise 'Not Implemented' end |
#kill(start_time, **params) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/worker_killer/killer.rb', line 14 def kill(start_time, **params) alive_sec = (Time.now - start_time).round @kill_attempts += 1 case @sig when nil @sig = :QUIT when :QUIT @sig = :TERM when :TERM @sig = :KILL end do_kill(@sig, Process.pid, alive_sec, **params) end |
#logger ⇒ Object
:nocov:
37 38 39 |
# File 'lib/worker_killer/killer.rb', line 37 def logger @logger ||= WorkerKiller.configuration.logger end |