class Sidekiq::Restart::Command

Public Class Methods

new(sidekiq) click to toggle source
# File lib/sidekiq/restart/command.rb, line 5
def initialize sidekiq
  @sidekiq = sidekiq
end

Public Instance Methods

run(id) click to toggle source
# 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