class Sidekiq::Process

Sidekiq::Process represents an active Sidekiq process talking with Redis. Each process has a set of attributes which look like this:

{

'hostname' => 'app-1.example.com',
'started_at' => <process start time>,
'pid' => 12345,
'tag' => 'myapp'
'concurrency' => 25,
'queues' => ['default', 'low'],
'busy' => 10,
'beat' => <last heartbeat>,
'identity' => <unique string identifying the process>,

}

Public Class Methods

new(hash) click to toggle source
# File lib/sidekiq/api.rb, line 795
def initialize(hash)
  @attribs = hash
end

Public Instance Methods

[](key) click to toggle source
# File lib/sidekiq/api.rb, line 807
def [](key)
  @attribs[key]
end
dump_threads() click to toggle source
# File lib/sidekiq/api.rb, line 823
def dump_threads
  signal('TTIN')
end
identity() click to toggle source
# File lib/sidekiq/api.rb, line 811
def identity
  self['identity']
end
labels() click to toggle source
# File lib/sidekiq/api.rb, line 803
def labels
  Array(self['labels'])
end
quiet!() click to toggle source
# File lib/sidekiq/api.rb, line 815
def quiet!
  signal('TSTP')
end
stop!() click to toggle source
# File lib/sidekiq/api.rb, line 819
def stop!
  signal('TERM')
end
stopping?() click to toggle source
# File lib/sidekiq/api.rb, line 827
def stopping?
  self['quiet'] == 'true'
end
tag() click to toggle source
# File lib/sidekiq/api.rb, line 799
def tag
  self['tag']
end

Private Instance Methods

signal(sig) click to toggle source
# File lib/sidekiq/api.rb, line 833
def signal(sig)
  key = "#{identity}-signals"
  Sidekiq.redis do |c|
    c.multi do
      c.lpush(key, sig)
      c.expire(key, 60)
    end
  end
end