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

Instance Method Details

#[](key) ⇒ Object



1030
1031
1032
# File 'lib/sidekiq/api.rb', line 1030

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.



1078
1079
1080
# File 'lib/sidekiq/api.rb', line 1078

def dump_threads
  signal("TTIN")
end

#embedded?Boolean

Returns:

  • (Boolean)


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

def embedded?
  self["embedded"]
end

#identityObject



1034
1035
1036
# File 'lib/sidekiq/api.rb', line 1034

def identity
  self["identity"]
end

#labelsObject



1026
1027
1028
# File 'lib/sidekiq/api.rb', line 1026

def labels
  self["labels"].to_a
end

#queuesObject



1038
1039
1040
# File 'lib/sidekiq/api.rb', line 1038

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.



1058
1059
1060
1061
1062
# File 'lib/sidekiq/api.rb', line 1058

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.



1068
1069
1070
1071
1072
# File 'lib/sidekiq/api.rb', line 1068

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



1083
1084
1085
# File 'lib/sidekiq/api.rb', line 1083

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

#tagObject



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

def tag
  self["tag"]
end

#versionObject



1046
1047
1048
# File 'lib/sidekiq/api.rb', line 1046

def version
  self["version"]
end

#weightsObject



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

def weights
  self["weights"]
end