Class: Sidekiq::Restart::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/restart/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(sidekiq) ⇒ Command

Returns a new instance of Command.



5
6
7
# File 'lib/sidekiq/restart/command.rb', line 5

def initialize sidekiq
  @sidekiq = sidekiq
end

Instance Method Details

#run(id) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sidekiq/restart/command.rb', line 9

def run id
  @sidekiq.redis do |conn|
    payload = conn.get("worker:#{id}")
    if payload
      msg = @sidekiq.load_json(payload)['payload']
      Sidekiq::Client.push msg

      # cleanup redis details about the worker
      conn.srem("workers", id)
      conn.del("worker:#{id}")
      conn.del("worker:#{id}:started")
    end
  end
end