Class: Sidekiq::Process
- Inherits:
-
Object
- Object
- Sidekiq::Process
- 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' => 5,
'capsules' => {"default" => {"mode" => "weighted", "concurrency" => 5, "weights" => {"default" => 2, "low" => 1}},
'busy' => 3,
'beat' => <last heartbeat>,
'identity' => <unique string identifying the process>,
'embedded' => true,
}
Instance Method Summary collapse
- #[](key) ⇒ Object
- #capsules ⇒ Object
-
#dump_threads ⇒ Object
Signal this process to log backtraces for all threads.
- #embedded? ⇒ Boolean
- #identity ⇒ Object (also: #id)
-
#initialize(hash) ⇒ Process
constructor
private
:nodoc:.
- #labels ⇒ Object
- #leader? ⇒ Boolean
-
#queues ⇒ Object
deprecated, use capsules below.
-
#quiet! ⇒ Object
Signal this process to stop processing new jobs.
-
#stop! ⇒ Object
Signal this process to shutdown.
-
#stopping? ⇒ Boolean
True if this process is quiet or shutting down.
- #tag ⇒ Object
- #version ⇒ Object
-
#weights ⇒ Object
deprecated, use capsules below.
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:
1110 1111 1112 |
# File 'lib/sidekiq/api.rb', line 1110 def initialize(hash) @attribs = hash end |
Instance Method Details
#[](key) ⇒ Object
1122 1123 1124 |
# File 'lib/sidekiq/api.rb', line 1122 def [](key) @attribs[key] end |
#capsules ⇒ Object
1158 1159 1160 |
# File 'lib/sidekiq/api.rb', line 1158 def capsules self["capsules"] end |
#dump_threads ⇒ Object
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.
1194 1195 1196 |
# File 'lib/sidekiq/api.rb', line 1194 def dump_threads signal("TTIN") end |
#embedded? ⇒ Boolean
1166 1167 1168 |
# File 'lib/sidekiq/api.rb', line 1166 def self["embedded"] end |
#identity ⇒ Object Also known as: id
1126 1127 1128 |
# File 'lib/sidekiq/api.rb', line 1126 def identity self["identity"] end |
#labels ⇒ Object
1118 1119 1120 |
# File 'lib/sidekiq/api.rb', line 1118 def labels self["labels"].to_a end |
#leader? ⇒ Boolean
1203 1204 1205 |
# File 'lib/sidekiq/api.rb', line 1203 def leader? Sidekiq.redis { |c| c.get("dear-leader") == identity } end |
#queues ⇒ Object
deprecated, use capsules below
1132 1133 1134 1135 1136 1137 1138 1139 |
# File 'lib/sidekiq/api.rb', line 1132 def queues # Backwards compatibility with <8.0.8 if !self["capsules"] self["queues"] else capsules.values.flat_map { |x| x["weights"].keys }.uniq end 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.
1174 1175 1176 1177 1178 |
# File 'lib/sidekiq/api.rb', line 1174 def quiet! raise "Can't quiet an embedded process" if 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.
1184 1185 1186 1187 1188 |
# File 'lib/sidekiq/api.rb', line 1184 def stop! raise "Can't stop an embedded process" if signal("TERM") end |
#stopping? ⇒ Boolean
Returns true if this process is quiet or shutting down.
1199 1200 1201 |
# File 'lib/sidekiq/api.rb', line 1199 def stopping? self["quiet"] == "true" end |
#tag ⇒ Object
1114 1115 1116 |
# File 'lib/sidekiq/api.rb', line 1114 def tag self["tag"] end |
#version ⇒ Object
1162 1163 1164 |
# File 'lib/sidekiq/api.rb', line 1162 def version self["version"] end |
#weights ⇒ Object
deprecated, use capsules below
1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 |
# File 'lib/sidekiq/api.rb', line 1142 def weights # Backwards compatibility with <8.0.8 if !self["capsules"] self["weights"] else hash = {} capsules.values.each do |cap| # Note: will lose data if two capsules are processing the same named queue cap["weights"].each_pair do |queue, weight| hash[queue] = weight end end hash end end |