sidekiq 6.1.2 → 6.2.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sidekiq might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Changes.md +49 -1
- data/lib/sidekiq/api.rb +22 -7
- data/lib/sidekiq/cli.rb +14 -1
- data/lib/sidekiq/client.rb +1 -5
- data/lib/sidekiq/fetch.rb +9 -1
- data/lib/sidekiq/job_retry.rb +1 -0
- data/lib/sidekiq/launcher.rb +58 -1
- data/lib/sidekiq/logger.rb +3 -2
- data/lib/sidekiq/util.rb +28 -0
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/web.rb +33 -78
- data/lib/sidekiq/web/action.rb +1 -1
- data/lib/sidekiq/web/application.rb +11 -3
- data/lib/sidekiq/web/csrf_protection.rb +28 -6
- data/lib/sidekiq/web/helpers.rb +23 -2
- data/lib/sidekiq/web/router.rb +4 -1
- data/sidekiq.gemspec +10 -2
- data/web/assets/images/apple-touch-icon.png +0 -0
- data/web/assets/stylesheets/application-dark.css +17 -0
- data/web/assets/stylesheets/application.css +17 -2
- data/web/locales/fr.yml +1 -1
- data/web/views/busy.erb +45 -14
- data/web/views/layout.erb +1 -0
- data/web/views/queue.erb +1 -1
- metadata +11 -26
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -20
- data/.github/contributing.md +0 -32
- data/.github/workflows/ci.yml +0 -41
- data/.gitignore +0 -13
- data/.standard.yml +0 -20
- data/3.0-Upgrade.md +0 -70
- data/4.0-Upgrade.md +0 -53
- data/5.0-Upgrade.md +0 -56
- data/6.0-Upgrade.md +0 -72
- data/COMM-LICENSE +0 -97
- data/Ent-2.0-Upgrade.md +0 -37
- data/Ent-Changes.md +0 -281
- data/Gemfile +0 -24
- data/Gemfile.lock +0 -192
- data/Pro-2.0-Upgrade.md +0 -138
- data/Pro-3.0-Upgrade.md +0 -44
- data/Pro-4.0-Upgrade.md +0 -35
- data/Pro-5.0-Upgrade.md +0 -25
- data/Pro-Changes.md +0 -805
- data/Rakefile +0 -10
- data/code_of_conduct.md +0 -50
data/lib/sidekiq/web/action.rb
CHANGED
@@ -4,7 +4,6 @@ module Sidekiq
|
|
4
4
|
class WebApplication
|
5
5
|
extend WebRouter
|
6
6
|
|
7
|
-
CONTENT_LENGTH = "Content-Length"
|
8
7
|
REDIS_KEYS = %w[redis_version uptime_in_days connected_clients used_memory_human used_memory_peak_human]
|
9
8
|
CSP_HEADER = [
|
10
9
|
"default-src 'self' https: http:",
|
@@ -42,6 +41,13 @@ module Sidekiq
|
|
42
41
|
# nothing, backwards compatibility
|
43
42
|
end
|
44
43
|
|
44
|
+
head "/" do
|
45
|
+
# HEAD / is the cheapest heartbeat possible,
|
46
|
+
# it hits Redis to ensure connectivity
|
47
|
+
Sidekiq.redis { |c| c.llen("queue:default") }
|
48
|
+
""
|
49
|
+
end
|
50
|
+
|
45
51
|
get "/" do
|
46
52
|
@redis_info = redis_info.select { |k, v| REDIS_KEYS.include? k }
|
47
53
|
stats_history = Sidekiq::Stats::History.new((params["days"] || 30).to_i)
|
@@ -76,10 +82,12 @@ module Sidekiq
|
|
76
82
|
erb(:queues)
|
77
83
|
end
|
78
84
|
|
85
|
+
QUEUE_NAME = /\A[a-z_:.\-0-9]+\z/i
|
86
|
+
|
79
87
|
get "/queues/:name" do
|
80
88
|
@name = route_params[:name]
|
81
89
|
|
82
|
-
halt(404)
|
90
|
+
halt(404) if !@name || @name !~ QUEUE_NAME
|
83
91
|
|
84
92
|
@count = (params["count"] || 25).to_i
|
85
93
|
@queue = Sidekiq::Queue.new(@name)
|
@@ -316,7 +324,7 @@ module Sidekiq
|
|
316
324
|
end
|
317
325
|
|
318
326
|
def self.helpers(mod = nil, &block)
|
319
|
-
if
|
327
|
+
if block
|
320
328
|
WebAction.class_eval(&block)
|
321
329
|
else
|
322
330
|
WebAction.send(:include, mod)
|
@@ -66,7 +66,31 @@ module Sidekiq
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def session(env)
|
69
|
-
env["rack.session"] || fail(
|
69
|
+
env["rack.session"] || fail(<<~EOM)
|
70
|
+
Sidekiq::Web needs a valid Rack session for CSRF protection. If this is a Rails app,
|
71
|
+
make sure you mount Sidekiq::Web *inside* your application routes:
|
72
|
+
|
73
|
+
|
74
|
+
Rails.application.routes.draw do
|
75
|
+
mount Sidekiq::Web => "/sidekiq"
|
76
|
+
....
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
If this is a Rails app in API mode, you need to enable sessions.
|
81
|
+
|
82
|
+
https://guides.rubyonrails.org/api_app.html#using-session-middlewares
|
83
|
+
|
84
|
+
If this is a bare Rack app, use a session middleware before Sidekiq::Web:
|
85
|
+
|
86
|
+
# first, use IRB to create a shared secret key for sessions and commit it
|
87
|
+
require 'securerandom'; File.open(".session.key", "w") {|f| f.write(SecureRandom.hex(32)) }
|
88
|
+
|
89
|
+
# now use the secret with a session cookie middleware
|
90
|
+
use Rack::Session::Cookie, secret: File.read(".session.key"), same_site: true, max_age: 86400
|
91
|
+
run Sidekiq::Web
|
92
|
+
|
93
|
+
EOM
|
70
94
|
end
|
71
95
|
|
72
96
|
def accept?(env)
|
@@ -90,13 +114,11 @@ module Sidekiq
|
|
90
114
|
end
|
91
115
|
|
92
116
|
sess = session(env)
|
93
|
-
|
94
|
-
# Checks that Rack::Session::Cookie did not return empty session
|
95
|
-
# object in case the digest verification failed
|
96
|
-
return false if sess.empty?
|
97
|
-
|
98
117
|
localtoken = sess[:csrf]
|
99
118
|
|
119
|
+
# Checks that Rack::Session::Cookie actualy contains the csrf toekn
|
120
|
+
return false if localtoken.nil?
|
121
|
+
|
100
122
|
# Rotate the session token after every use
|
101
123
|
sess[:csrf] = SecureRandom.base64(TOKEN_LENGTH)
|
102
124
|
|
data/lib/sidekiq/web/helpers.rb
CHANGED
@@ -22,6 +22,14 @@ module Sidekiq
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def singularize(str, count)
|
26
|
+
if count == 1 && str.respond_to?(:singularize) # rails
|
27
|
+
str.singularize
|
28
|
+
else
|
29
|
+
str
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
25
33
|
def clear_caches
|
26
34
|
@strings = nil
|
27
35
|
@locale_files = nil
|
@@ -158,8 +166,7 @@ module Sidekiq
|
|
158
166
|
|
159
167
|
def redis_connection
|
160
168
|
Sidekiq.redis do |conn|
|
161
|
-
|
162
|
-
"redis://#{c[:location]}/#{c[:db]}"
|
169
|
+
conn.connection[:id]
|
163
170
|
end
|
164
171
|
end
|
165
172
|
|
@@ -258,7 +265,21 @@ module Sidekiq
|
|
258
265
|
end
|
259
266
|
end
|
260
267
|
|
268
|
+
def format_memory(rss_kb)
|
269
|
+
return "0" if rss_kb.nil? || rss_kb == 0
|
270
|
+
|
271
|
+
if rss_kb < 100_000
|
272
|
+
"#{number_with_delimiter(rss_kb)} KB"
|
273
|
+
elsif rss_kb < 10_000_000
|
274
|
+
"#{number_with_delimiter((rss_kb / 1024.0).to_i)} MB"
|
275
|
+
else
|
276
|
+
"#{number_with_delimiter((rss_kb / (1024.0 * 1024.0)).round(1))} GB"
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
261
280
|
def number_with_delimiter(number)
|
281
|
+
return "" if number.nil?
|
282
|
+
|
262
283
|
begin
|
263
284
|
Float(number)
|
264
285
|
rescue ArgumentError, TypeError
|
data/lib/sidekiq/web/router.rb
CHANGED
@@ -15,6 +15,10 @@ module Sidekiq
|
|
15
15
|
REQUEST_METHOD = "REQUEST_METHOD"
|
16
16
|
PATH_INFO = "PATH_INFO"
|
17
17
|
|
18
|
+
def head(path, &block)
|
19
|
+
route(HEAD, path, &block)
|
20
|
+
end
|
21
|
+
|
18
22
|
def get(path, &block)
|
19
23
|
route(GET, path, &block)
|
20
24
|
end
|
@@ -39,7 +43,6 @@ module Sidekiq
|
|
39
43
|
@routes ||= {GET => [], POST => [], PUT => [], PATCH => [], DELETE => [], HEAD => []}
|
40
44
|
|
41
45
|
@routes[method] << WebRoute.new(method, path, block)
|
42
|
-
@routes[HEAD] << WebRoute.new(method, path, block) if method == GET
|
43
46
|
end
|
44
47
|
|
45
48
|
def match(env)
|
data/sidekiq.gemspec
CHANGED
@@ -5,15 +5,23 @@ Gem::Specification.new do |gem|
|
|
5
5
|
gem.email = ["mperham@gmail.com"]
|
6
6
|
gem.summary = "Simple, efficient background processing for Ruby"
|
7
7
|
gem.description = "Simple, efficient background processing for Ruby."
|
8
|
-
gem.homepage = "
|
8
|
+
gem.homepage = "https://sidekiq.org"
|
9
9
|
gem.license = "LGPL-3.0"
|
10
10
|
|
11
11
|
gem.executables = ["sidekiq", "sidekiqmon"]
|
12
|
-
gem.files = `git ls-files | grep -
|
12
|
+
gem.files = ["sidekiq.gemspec", "README.md", "Changes.md", "LICENSE"] + `git ls-files | grep -E '^(bin|lib|web)'`.split("\n")
|
13
13
|
gem.name = "sidekiq"
|
14
14
|
gem.version = Sidekiq::VERSION
|
15
15
|
gem.required_ruby_version = ">= 2.5.0"
|
16
16
|
|
17
|
+
gem.metadata = {
|
18
|
+
"homepage_uri" => "https://sidekiq.org",
|
19
|
+
"bug_tracker_uri" => "https://github.com/mperham/sidekiq/issues",
|
20
|
+
"documentation_uri" => "https://github.com/mperham/sidekiq/wiki",
|
21
|
+
"changelog_uri" => "https://github.com/mperham/sidekiq/blob/master/Changes.md",
|
22
|
+
"source_code_uri" => "https://github.com/mperham/sidekiq"
|
23
|
+
}
|
24
|
+
|
17
25
|
gem.add_dependency "redis", ">= 4.2.0"
|
18
26
|
gem.add_dependency "connection_pool", ">= 2.2.2"
|
19
27
|
gem.add_dependency "rack", "~> 2.0"
|
Binary file
|
@@ -75,6 +75,12 @@ a.btn {
|
|
75
75
|
color: #000;
|
76
76
|
}
|
77
77
|
|
78
|
+
input {
|
79
|
+
background-color: #444;
|
80
|
+
color: #ccc;
|
81
|
+
padding: 3px;
|
82
|
+
}
|
83
|
+
|
78
84
|
.summary_bar .summary {
|
79
85
|
background-color: #222;
|
80
86
|
border: 1px solid #555;
|
@@ -141,3 +147,14 @@ a.btn {
|
|
141
147
|
fill: #ddd;
|
142
148
|
color: #ddd;
|
143
149
|
}
|
150
|
+
|
151
|
+
.info-circle {
|
152
|
+
color: #282828;
|
153
|
+
background-color: #555555;
|
154
|
+
border-radius: 50%;
|
155
|
+
text-align: center;
|
156
|
+
vertical-align: middle;
|
157
|
+
padding: 3px 7px;
|
158
|
+
font-size: 0.7em;
|
159
|
+
margin-left: 5px;
|
160
|
+
}
|
@@ -127,6 +127,10 @@ header.row .pagination {
|
|
127
127
|
width: 14%;
|
128
128
|
}
|
129
129
|
@media (max-width: 767px) and (min-width: 200px) {
|
130
|
+
.summary_bar {
|
131
|
+
font-size: 1.5em;
|
132
|
+
}
|
133
|
+
|
130
134
|
.summary_bar ul li {
|
131
135
|
width: 100%;
|
132
136
|
}
|
@@ -186,7 +190,7 @@ form .btn {
|
|
186
190
|
}
|
187
191
|
|
188
192
|
form .btn-group .btn {
|
189
|
-
margin-right:
|
193
|
+
margin-right: 4px;
|
190
194
|
}
|
191
195
|
|
192
196
|
td form {
|
@@ -438,7 +442,7 @@ img.smallogo {
|
|
438
442
|
margin: 5px 10px 5px 5px;
|
439
443
|
}
|
440
444
|
.stat p{
|
441
|
-
font-size:
|
445
|
+
font-size: 1.5em;
|
442
446
|
margin: 5px 5px 5px 10px;
|
443
447
|
}
|
444
448
|
}
|
@@ -1152,3 +1156,14 @@ div.interval-slider input {
|
|
1152
1156
|
.delete-confirm {
|
1153
1157
|
width: 20%;
|
1154
1158
|
}
|
1159
|
+
|
1160
|
+
.info-circle {
|
1161
|
+
color: #f3f3f3;
|
1162
|
+
background-color: #dddddd;
|
1163
|
+
border-radius: 50%;
|
1164
|
+
text-align: center;
|
1165
|
+
vertical-align: middle;
|
1166
|
+
padding: 3px 7px;
|
1167
|
+
font-size: 0.7em;
|
1168
|
+
margin-left: 5px;
|
1169
|
+
}
|
data/web/locales/fr.yml
CHANGED
data/web/views/busy.erb
CHANGED
@@ -1,8 +1,39 @@
|
|
1
1
|
<div class="row header">
|
2
|
-
<div class="col-sm-
|
2
|
+
<div class="col-sm-4 pull-left flip">
|
3
|
+
<h3><%= t('Status') %></h3>
|
4
|
+
</div>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<div class="table_container">
|
8
|
+
<div class="stats-container">
|
9
|
+
<div class="stat">
|
10
|
+
<h3><%= s = processes.size; number_with_delimiter(s) %></h3>
|
11
|
+
<p><%= t('Processes') %></p>
|
12
|
+
</div>
|
13
|
+
<div class="stat">
|
14
|
+
<h3><%= x = processes.total_concurrency; number_with_delimiter(x) %></h3>
|
15
|
+
<p><%= t('Threads') %></p>
|
16
|
+
</div>
|
17
|
+
<div class="stat">
|
18
|
+
<h3><%= ws = workers.size; number_with_delimiter(ws) %></h3>
|
19
|
+
<p><%= t('Busy') %></p>
|
20
|
+
</div>
|
21
|
+
<div class="stat">
|
22
|
+
<h3><%= x == 0 ? 0 : ((ws / x.to_f) * 100).round(0) %>%</h3>
|
23
|
+
<p><%= t('Utilization') %></p>
|
24
|
+
</div>
|
25
|
+
<div class="stat">
|
26
|
+
<h3><%= format_memory(processes.total_rss) %></h3>
|
27
|
+
<p><%= t('RSS') %></p>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<div class="row header">
|
33
|
+
<div class="col-sm-4 pull-left flip">
|
3
34
|
<h3><%= t('Processes') %></h3>
|
4
35
|
</div>
|
5
|
-
<div class="col-sm-
|
36
|
+
<div class="col-sm-3 pull-right flip">
|
6
37
|
<form method="POST" class="warning-messages">
|
7
38
|
<%= csrf_tag %>
|
8
39
|
<div class="btn-group pull-right flip">
|
@@ -12,14 +43,14 @@
|
|
12
43
|
</form>
|
13
44
|
</div>
|
14
45
|
</div>
|
15
|
-
|
16
46
|
<div class="table_container">
|
17
47
|
<table class="processes table table-hover table-bordered table-striped">
|
18
48
|
<thead>
|
19
49
|
<th><%= t('Name') %></th>
|
20
50
|
<th><%= t('Started') %></th>
|
21
|
-
<th><%= t('
|
22
|
-
<th><%= t('
|
51
|
+
<th class="col-sm-1"><%= t('RSS') %><a href="https://github.com/mperham/sidekiq/wiki/Memory#rss"><span class="info-circle" title="Click to learn more about RSS">?</span></a></th>
|
52
|
+
<th class="col-sm-1"><%= t('Threads') %></th>
|
53
|
+
<th class="col-sm-1"><%= t('Busy') %></th>
|
23
54
|
<th> </th>
|
24
55
|
</thead>
|
25
56
|
<% lead = processes.leader %>
|
@@ -42,19 +73,19 @@
|
|
42
73
|
<%= process['queues'] * ", " %>
|
43
74
|
</td>
|
44
75
|
<td><%= relative_time(Time.at(process['started_at'])) %></td>
|
76
|
+
<td><%= format_memory(process['rss'].to_i) %></td>
|
45
77
|
<td><%= process['concurrency'] %></td>
|
46
78
|
<td><%= process['busy'] %></td>
|
47
79
|
<td>
|
48
|
-
<
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
<% end %>
|
80
|
+
<form method="POST">
|
81
|
+
<%= csrf_tag %>
|
82
|
+
<input type="hidden" name="identity" value="<%= process['identity'] %>"/>
|
83
|
+
|
84
|
+
<div class="btn-group pull-right flip">
|
85
|
+
<% unless process.stopping? %><button class="btn btn-warn" type="submit" name="quiet" value="1"><%= t('Quiet') %></button><% end %>
|
55
86
|
<button class="btn btn-danger" type="submit" name="stop" value="1"><%= t('Stop') %></button>
|
56
|
-
</
|
57
|
-
</
|
87
|
+
</div>
|
88
|
+
</form>
|
58
89
|
</td>
|
59
90
|
</tr>
|
60
91
|
<% end %>
|
data/web/views/layout.erb
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
<link href="<%= root_path %>stylesheets/application-rtl.css" media="screen" rel="stylesheet" type="text/css" />
|
17
17
|
<% end %>
|
18
18
|
|
19
|
+
<link rel="apple-touch-icon" href="<%= root_path %>images/apple-touch-icon.png">
|
19
20
|
<link rel="shortcut icon" type="image/ico" href="<%= root_path %>images/favicon.ico" />
|
20
21
|
<script type="text/javascript" src="<%= root_path %>javascripts/application.js"></script>
|
21
22
|
<meta name="google" content="notranslate" />
|
data/web/views/queue.erb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.1
|
4
|
+
version: 6.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Perham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -61,33 +61,12 @@ executables:
|
|
61
61
|
extensions: []
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
|
-
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
65
|
-
- ".github/contributing.md"
|
66
|
-
- ".github/workflows/ci.yml"
|
67
|
-
- ".gitignore"
|
68
|
-
- ".standard.yml"
|
69
|
-
- 3.0-Upgrade.md
|
70
|
-
- 4.0-Upgrade.md
|
71
|
-
- 5.0-Upgrade.md
|
72
|
-
- 6.0-Upgrade.md
|
73
|
-
- COMM-LICENSE
|
74
64
|
- Changes.md
|
75
|
-
- Ent-2.0-Upgrade.md
|
76
|
-
- Ent-Changes.md
|
77
|
-
- Gemfile
|
78
|
-
- Gemfile.lock
|
79
65
|
- LICENSE
|
80
|
-
- Pro-2.0-Upgrade.md
|
81
|
-
- Pro-3.0-Upgrade.md
|
82
|
-
- Pro-4.0-Upgrade.md
|
83
|
-
- Pro-5.0-Upgrade.md
|
84
|
-
- Pro-Changes.md
|
85
66
|
- README.md
|
86
|
-
- Rakefile
|
87
67
|
- bin/sidekiq
|
88
68
|
- bin/sidekiqload
|
89
69
|
- bin/sidekiqmon
|
90
|
-
- code_of_conduct.md
|
91
70
|
- lib/generators/sidekiq/templates/worker.rb.erb
|
92
71
|
- lib/generators/sidekiq/templates/worker_spec.rb.erb
|
93
72
|
- lib/generators/sidekiq/templates/worker_test.rb.erb
|
@@ -130,6 +109,7 @@ files:
|
|
130
109
|
- lib/sidekiq/web/router.rb
|
131
110
|
- lib/sidekiq/worker.rb
|
132
111
|
- sidekiq.gemspec
|
112
|
+
- web/assets/images/apple-touch-icon.png
|
133
113
|
- web/assets/images/favicon.ico
|
134
114
|
- web/assets/images/logo.png
|
135
115
|
- web/assets/images/status.png
|
@@ -186,10 +166,15 @@ files:
|
|
186
166
|
- web/views/retry.erb
|
187
167
|
- web/views/scheduled.erb
|
188
168
|
- web/views/scheduled_job_info.erb
|
189
|
-
homepage:
|
169
|
+
homepage: https://sidekiq.org
|
190
170
|
licenses:
|
191
171
|
- LGPL-3.0
|
192
|
-
metadata:
|
172
|
+
metadata:
|
173
|
+
homepage_uri: https://sidekiq.org
|
174
|
+
bug_tracker_uri: https://github.com/mperham/sidekiq/issues
|
175
|
+
documentation_uri: https://github.com/mperham/sidekiq/wiki
|
176
|
+
changelog_uri: https://github.com/mperham/sidekiq/blob/master/Changes.md
|
177
|
+
source_code_uri: https://github.com/mperham/sidekiq
|
193
178
|
post_install_message:
|
194
179
|
rdoc_options: []
|
195
180
|
require_paths:
|
@@ -205,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
190
|
- !ruby/object:Gem::Version
|
206
191
|
version: '0'
|
207
192
|
requirements: []
|
208
|
-
rubygems_version: 3.1.
|
193
|
+
rubygems_version: 3.1.4
|
209
194
|
signing_key:
|
210
195
|
specification_version: 4
|
211
196
|
summary: Simple, efficient background processing for Ruby
|