Class: WorkerKiller::Killer::DelayedJob

Inherits:
Base
  • Object
show all
Defined in:
lib/worker_killer/killer/delayed_job.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #kill_attempts

Instance Method Summary collapse

Methods inherited from Base

#initialize, #kill, #logger

Constructor Details

This class inherits a constructor from WorkerKiller::Killer::Base

Instance Method Details

#do_kill(sig, pid, alive_sec, dj:, **_params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/worker_killer/killer/delayed_job.rb', line 5

def do_kill(sig, pid, alive_sec, dj:, **_params)
  if sig == :KILL
    logger.error "#{self.class}: force to #{sig} self (pid: #{pid}) alive: #{alive_sec} sec (trial #{kill_attempts})"
    Process.kill sig, pid
    return
  end

  dj.stop
  logger.info "#{self.class}: try to stop DelayedJob due to #{sig} self (pid: #{pid}) alive: #{alive_sec} sec (trial #{kill_attempts})"

  return if sig != :TERM

  if @termination
    logger.warn "#{self.class}: force to #{sig} self (pid: #{pid}) alive: #{alive_sec} sec (trial #{kill_attempts})"
    Process.kill sig, pid
  else
    @termination = true
  end
end