Class: Sidekiq::Process

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

Overview

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>,
'embedded' => true,

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Process

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

:nodoc:



991
992
993
# File 'lib/sidekiq/api.rb', line 991

def initialize(hash)
  @attribs = hash
end

Instance Method Details

#[](key) ⇒ Object



1003
1004
1005
# File 'lib/sidekiq/api.rb', line 1003

def [](key)
  @attribs[key]
end

#dump_threadsObject

Signal this process to log backtraces for all threads. Useful if you have a frozen or deadlocked process which is still sending a heartbeat. This method is asynchronous and it can take 5-10 seconds.



1051
1052
1053
# File 'lib/sidekiq/api.rb', line 1051

def dump_threads
  signal("TTIN")
end

#embedded?Boolean

Returns:

  • (Boolean)


1023
1024
1025
# File 'lib/sidekiq/api.rb', line 1023

def embedded?
  self["embedded"]
end

#identityObject



1007
1008
1009
# File 'lib/sidekiq/api.rb', line 1007

def identity
  self["identity"]
end

#labelsObject



999
1000
1001
# File 'lib/sidekiq/api.rb', line 999

def labels
  self["labels"].to_a
end

#queuesObject



1011
1012
1013
# File 'lib/sidekiq/api.rb', line 1011

def queues
  self["queues"]
end

#quiet!Object

Signal this process to stop processing new jobs. It will continue to execute jobs it has already fetched. This method is asynchronous and it can take 5-10 seconds for the process to quiet.



1031
1032
1033
1034
1035
# File 'lib/sidekiq/api.rb', line 1031

def quiet!
  raise "Can't quiet an embedded process" if embedded?

  signal("TSTP")
end

#stop!Object

Signal this process to shutdown. It will shutdown within its configured :timeout value, default 25 seconds. This method is asynchronous and it can take 5-10 seconds for the process to start shutting down.



1041
1042
1043
1044
1045
# File 'lib/sidekiq/api.rb', line 1041

def stop!
  raise "Can't stop an embedded process" if embedded?

  signal("TERM")
end

#stopping?Boolean

Returns true if this process is quiet or shutting down.

Returns:

  • (Boolean)

    true if this process is quiet or shutting down



1056
1057
1058
# File 'lib/sidekiq/api.rb', line 1056

def stopping?
  self["quiet"] == "true"
end

#tagObject



995
996
997
# File 'lib/sidekiq/api.rb', line 995

def tag
  self["tag"]
end

#versionObject



1019
1020
1021
# File 'lib/sidekiq/api.rb', line 1019

def version
  self["version"]
end

#weightsObject



1015
1016
1017
# File 'lib/sidekiq/api.rb', line 1015

def weights
  self["weights"]
end