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



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

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.



1080
1081
1082
# File 'lib/sidekiq/api.rb', line 1080

def dump_threads
  signal("TTIN")
end

#embedded?Boolean

Returns:

  • (Boolean)


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

def embedded?
  self["embedded"]
end

#identityObject



1036
1037
1038
# File 'lib/sidekiq/api.rb', line 1036

def identity
  self["identity"]
end

#labelsObject



1028
1029
1030
# File 'lib/sidekiq/api.rb', line 1028

def labels
  self["labels"].to_a
end

#queuesObject



1040
1041
1042
# File 'lib/sidekiq/api.rb', line 1040

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.



1060
1061
1062
1063
1064
# File 'lib/sidekiq/api.rb', line 1060

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.



1070
1071
1072
1073
1074
# File 'lib/sidekiq/api.rb', line 1070

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



1085
1086
1087
# File 'lib/sidekiq/api.rb', line 1085

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

#tagObject



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

def tag
  self["tag"]
end

#versionObject



1048
1049
1050
# File 'lib/sidekiq/api.rb', line 1048

def version
  self["version"]
end

#weightsObject



1044
1045
1046
# File 'lib/sidekiq/api.rb', line 1044

def weights
  self["weights"]
end