sidekiq 5.2.1 → 6.0.0
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 +5 -5
- data/.circleci/config.yml +61 -0
- data/.gitignore +1 -1
- data/.standard.yml +20 -0
- data/6.0-Upgrade.md +70 -0
- data/COMM-LICENSE +11 -9
- data/Changes.md +79 -0
- data/Ent-2.0-Upgrade.md +37 -0
- data/Ent-Changes.md +30 -1
- data/Gemfile +19 -9
- data/Gemfile.lock +196 -0
- data/Pro-5.0-Upgrade.md +25 -0
- data/Pro-Changes.md +29 -0
- data/README.md +17 -31
- data/Rakefile +6 -4
- data/bin/sidekiqload +27 -23
- data/bin/sidekiqmon +9 -0
- data/lib/generators/sidekiq/templates/worker_test.rb.erb +1 -1
- data/lib/generators/sidekiq/worker_generator.rb +12 -14
- data/lib/sidekiq.rb +56 -43
- data/lib/sidekiq/api.rb +141 -148
- data/lib/sidekiq/cli.rb +142 -207
- data/lib/sidekiq/client.rb +45 -46
- data/lib/sidekiq/delay.rb +5 -6
- data/lib/sidekiq/exception_handler.rb +10 -12
- data/lib/sidekiq/extensions/action_mailer.rb +10 -20
- data/lib/sidekiq/extensions/active_record.rb +9 -7
- data/lib/sidekiq/extensions/class_methods.rb +9 -7
- data/lib/sidekiq/extensions/generic_proxy.rb +4 -4
- data/lib/sidekiq/fetch.rb +5 -6
- data/lib/sidekiq/job_logger.rb +39 -9
- data/lib/sidekiq/job_retry.rb +62 -54
- data/lib/sidekiq/launcher.rb +60 -52
- data/lib/sidekiq/logger.rb +69 -0
- data/lib/sidekiq/manager.rb +10 -12
- data/lib/sidekiq/middleware/chain.rb +3 -2
- data/lib/sidekiq/middleware/i18n.rb +5 -7
- data/lib/sidekiq/monitor.rb +148 -0
- data/lib/sidekiq/paginator.rb +11 -12
- data/lib/sidekiq/processor.rb +98 -62
- data/lib/sidekiq/rails.rb +24 -29
- data/lib/sidekiq/redis_connection.rb +34 -21
- data/lib/sidekiq/scheduled.rb +17 -19
- data/lib/sidekiq/testing.rb +22 -23
- data/lib/sidekiq/testing/inline.rb +2 -1
- data/lib/sidekiq/util.rb +17 -14
- data/lib/sidekiq/version.rb +2 -1
- data/lib/sidekiq/web.rb +41 -49
- data/lib/sidekiq/web/action.rb +14 -10
- data/lib/sidekiq/web/application.rb +67 -58
- data/lib/sidekiq/web/helpers.rb +72 -66
- data/lib/sidekiq/web/router.rb +17 -14
- data/lib/sidekiq/worker.rb +134 -91
- data/sidekiq.gemspec +16 -18
- data/web/assets/javascripts/dashboard.js +14 -23
- data/web/assets/stylesheets/application.css +35 -2
- data/web/assets/stylesheets/bootstrap.css +1 -1
- data/web/locales/ar.yml +1 -0
- data/web/locales/en.yml +1 -0
- data/web/locales/ja.yml +2 -1
- data/web/views/_nav.erb +3 -17
- data/web/views/queue.erb +1 -0
- data/web/views/queues.erb +1 -1
- data/web/views/retries.erb +4 -0
- metadata +31 -26
- data/.travis.yml +0 -14
- data/bin/sidekiqctl +0 -99
- data/lib/sidekiq/core_ext.rb +0 -1
- data/lib/sidekiq/logging.rb +0 -122
- data/lib/sidekiq/middleware/server/active_record.rb +0 -23
data/lib/sidekiq/version.rb
CHANGED
data/lib/sidekiq/web.rb
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'erb'
|
3
2
|
|
4
|
-
require
|
5
|
-
require 'sidekiq/api'
|
6
|
-
require 'sidekiq/paginator'
|
7
|
-
require 'sidekiq/web/helpers'
|
3
|
+
require "erb"
|
8
4
|
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
5
|
+
require "sidekiq"
|
6
|
+
require "sidekiq/api"
|
7
|
+
require "sidekiq/paginator"
|
8
|
+
require "sidekiq/web/helpers"
|
12
9
|
|
13
|
-
require
|
10
|
+
require "sidekiq/web/router"
|
11
|
+
require "sidekiq/web/action"
|
12
|
+
require "sidekiq/web/application"
|
14
13
|
|
15
|
-
require
|
16
|
-
|
17
|
-
require
|
14
|
+
require "rack/protection"
|
15
|
+
|
16
|
+
require "rack/builder"
|
17
|
+
require "rack/file"
|
18
|
+
require "rack/session/cookie"
|
18
19
|
|
19
20
|
module Sidekiq
|
20
21
|
class Web
|
@@ -25,12 +26,12 @@ module Sidekiq
|
|
25
26
|
ASSETS = "#{ROOT}/assets"
|
26
27
|
|
27
28
|
DEFAULT_TABS = {
|
28
|
-
"Dashboard" =>
|
29
|
-
"Busy"
|
30
|
-
"Queues"
|
31
|
-
"Retries"
|
32
|
-
"Scheduled" =>
|
33
|
-
"Dead"
|
29
|
+
"Dashboard" => "",
|
30
|
+
"Busy" => "busy",
|
31
|
+
"Queues" => "queues",
|
32
|
+
"Retries" => "retries",
|
33
|
+
"Scheduled" => "scheduled",
|
34
|
+
"Dead" => "morgue",
|
34
35
|
}
|
35
36
|
|
36
37
|
class << self
|
@@ -64,11 +65,11 @@ module Sidekiq
|
|
64
65
|
end
|
65
66
|
|
66
67
|
def enable(*opts)
|
67
|
-
opts.each {|key| set(key, true) }
|
68
|
+
opts.each { |key| set(key, true) }
|
68
69
|
end
|
69
70
|
|
70
71
|
def disable(*opts)
|
71
|
-
opts.each {|key| set(key, false) }
|
72
|
+
opts.each { |key| set(key, false) }
|
72
73
|
end
|
73
74
|
|
74
75
|
# Helper for the Sinatra syntax: Sidekiq::Web.set(:session_secret, Rails.application.secrets...)
|
@@ -81,10 +82,10 @@ module Sidekiq
|
|
81
82
|
end
|
82
83
|
|
83
84
|
def self.inherited(child)
|
84
|
-
child.app_url =
|
85
|
-
child.session_secret =
|
86
|
-
child.redis_pool =
|
87
|
-
child.sessions =
|
85
|
+
child.app_url = app_url
|
86
|
+
child.session_secret = session_secret
|
87
|
+
child.redis_pool = redis_pool
|
88
|
+
child.sessions = sessions
|
88
89
|
end
|
89
90
|
|
90
91
|
def settings
|
@@ -113,11 +114,11 @@ module Sidekiq
|
|
113
114
|
end
|
114
115
|
|
115
116
|
def enable(*opts)
|
116
|
-
opts.each {|key| set(key, true) }
|
117
|
+
opts.each { |key| set(key, true) }
|
117
118
|
end
|
118
119
|
|
119
120
|
def disable(*opts)
|
120
|
-
opts.each {|key| set(key, false) }
|
121
|
+
opts.each { |key| set(key, false) }
|
121
122
|
end
|
122
123
|
|
123
124
|
def set(attribute, value)
|
@@ -145,28 +146,28 @@ module Sidekiq
|
|
145
146
|
private
|
146
147
|
|
147
148
|
def using?(middleware)
|
148
|
-
middlewares.any? do |(m,_)|
|
149
|
-
m.
|
149
|
+
middlewares.any? do |(m, _)|
|
150
|
+
m.is_a?(Array) && (m[0] == middleware || m[0].is_a?(middleware))
|
150
151
|
end
|
151
152
|
end
|
152
153
|
|
153
154
|
def build_sessions
|
154
155
|
middlewares = self.middlewares
|
155
156
|
|
156
|
-
unless using?(::Rack::Protection) || ENV[
|
157
|
-
middlewares.unshift [[::Rack::Protection, {
|
157
|
+
unless using?(::Rack::Protection) || ENV["RACK_ENV"] == "test"
|
158
|
+
middlewares.unshift [[::Rack::Protection, {use: :authenticity_token}], nil]
|
158
159
|
end
|
159
160
|
|
160
161
|
s = sessions
|
161
162
|
return unless s
|
162
163
|
|
163
164
|
unless using? ::Rack::Session::Cookie
|
164
|
-
unless secret = Web.session_secret
|
165
|
-
require
|
165
|
+
unless (secret = Web.session_secret)
|
166
|
+
require "securerandom"
|
166
167
|
secret = SecureRandom.hex(64)
|
167
168
|
end
|
168
169
|
|
169
|
-
options = {
|
170
|
+
options = {secret: secret}
|
170
171
|
options = options.merge(s.to_hash) if s.respond_to? :to_hash
|
171
172
|
|
172
173
|
middlewares.unshift [[::Rack::Session::Cookie, options], nil]
|
@@ -180,13 +181,13 @@ module Sidekiq
|
|
180
181
|
klass = self.class
|
181
182
|
|
182
183
|
::Rack::Builder.new do
|
183
|
-
%w
|
184
|
+
%w[stylesheets javascripts images].each do |asset_dir|
|
184
185
|
map "/#{asset_dir}" do
|
185
|
-
run ::Rack::File.new("#{ASSETS}/#{asset_dir}", {
|
186
|
+
run ::Rack::File.new("#{ASSETS}/#{asset_dir}", {"Cache-Control" => "public, max-age=86400"})
|
186
187
|
end
|
187
188
|
end
|
188
189
|
|
189
|
-
middlewares.each {|middleware, block| use(*middleware, &block) }
|
190
|
+
middlewares.each { |middleware, block| use(*middleware, &block) }
|
190
191
|
|
191
192
|
run WebApplication.new(klass)
|
192
193
|
end
|
@@ -196,18 +197,9 @@ module Sidekiq
|
|
196
197
|
Sidekiq::WebApplication.helpers WebHelpers
|
197
198
|
Sidekiq::WebApplication.helpers Sidekiq::Paginator
|
198
199
|
|
199
|
-
Sidekiq::WebAction.class_eval
|
200
|
-
|
201
|
-
|
202
|
-
if defined?(::ActionDispatch::Request::Session) &&
|
203
|
-
!::ActionDispatch::Request::Session.method_defined?(:each)
|
204
|
-
# mperham/sidekiq#2460
|
205
|
-
# Rack apps can't reuse the Rails session store without
|
206
|
-
# this monkeypatch, fixed in Rails 5.
|
207
|
-
class ActionDispatch::Request::Session
|
208
|
-
def each(&block)
|
209
|
-
hash = self.to_hash
|
210
|
-
hash.each(&block)
|
200
|
+
Sidekiq::WebAction.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
201
|
+
def _render
|
202
|
+
#{ERB.new(File.read(Web::LAYOUT)).src}
|
211
203
|
end
|
212
|
-
|
204
|
+
RUBY
|
213
205
|
end
|
data/lib/sidekiq/web/action.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Sidekiq
|
4
4
|
class WebAction
|
5
|
-
RACK_SESSION =
|
5
|
+
RACK_SESSION = "rack.session"
|
6
6
|
|
7
7
|
attr_accessor :env, :block, :type
|
8
8
|
|
@@ -19,14 +19,14 @@ module Sidekiq
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def redirect(location)
|
22
|
-
throw :halt, [302, {
|
22
|
+
throw :halt, [302, {"Location" => "#{request.base_url}#{location}"}, []]
|
23
23
|
end
|
24
24
|
|
25
25
|
def params
|
26
|
-
indifferent_hash = Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
|
26
|
+
indifferent_hash = Hash.new { |hash, key| hash[key.to_s] if Symbol === key }
|
27
27
|
|
28
28
|
indifferent_hash.merge! request.params
|
29
|
-
route_params.each {|k,v| indifferent_hash[k.to_s] = v }
|
29
|
+
route_params.each { |k, v| indifferent_hash[k.to_s] = v }
|
30
30
|
|
31
31
|
indifferent_hash
|
32
32
|
end
|
@@ -40,10 +40,14 @@ module Sidekiq
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def erb(content, options = {})
|
43
|
-
if content.
|
43
|
+
if content.is_a? Symbol
|
44
44
|
unless respond_to?(:"_erb_#{content}")
|
45
45
|
src = ERB.new(File.read("#{Web.settings.views}/#{content}.erb")).src
|
46
|
-
WebAction.class_eval
|
46
|
+
WebAction.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
47
|
+
def _erb_#{content}
|
48
|
+
#{src}
|
49
|
+
end
|
50
|
+
RUBY
|
47
51
|
end
|
48
52
|
end
|
49
53
|
|
@@ -64,22 +68,22 @@ module Sidekiq
|
|
64
68
|
end
|
65
69
|
|
66
70
|
def json(payload)
|
67
|
-
[200, {
|
71
|
+
[200, {"Content-Type" => "application/json", "Cache-Control" => "no-cache"}, [Sidekiq.dump_json(payload)]]
|
68
72
|
end
|
69
73
|
|
70
74
|
def initialize(env, block)
|
71
75
|
@_erb = false
|
72
76
|
@env = env
|
73
77
|
@block = block
|
74
|
-
|
78
|
+
@files ||= {}
|
75
79
|
end
|
76
80
|
|
77
81
|
private
|
78
82
|
|
79
83
|
def _erb(file, locals)
|
80
|
-
locals
|
84
|
+
locals&.each { |k, v| define_singleton_method(k) { v } unless singleton_methods.include? k }
|
81
85
|
|
82
|
-
if file.
|
86
|
+
if file.is_a?(String)
|
83
87
|
ERB.new(file).result(binding)
|
84
88
|
else
|
85
89
|
send(:"_erb_#{file}")
|
@@ -6,7 +6,7 @@ module Sidekiq
|
|
6
6
|
|
7
7
|
CONTENT_LENGTH = "Content-Length"
|
8
8
|
CONTENT_TYPE = "Content-Type"
|
9
|
-
REDIS_KEYS = %w
|
9
|
+
REDIS_KEYS = %w[redis_version uptime_in_days connected_clients used_memory_human used_memory_peak_human]
|
10
10
|
CSP_HEADER = [
|
11
11
|
"default-src 'self' https: http:",
|
12
12
|
"child-src 'self'",
|
@@ -17,11 +17,11 @@ module Sidekiq
|
|
17
17
|
"manifest-src 'self'",
|
18
18
|
"media-src 'self'",
|
19
19
|
"object-src 'none'",
|
20
|
-
"script-src 'self' https: http:",
|
20
|
+
"script-src 'self' https: http: 'unsafe-inline'",
|
21
21
|
"style-src 'self' https: http: 'unsafe-inline'",
|
22
22
|
"worker-src 'self'",
|
23
|
-
"base-uri 'self'"
|
24
|
-
].join(
|
23
|
+
"base-uri 'self'",
|
24
|
+
].join("; ").freeze
|
25
25
|
|
26
26
|
def initialize(klass)
|
27
27
|
@klass = klass
|
@@ -44,8 +44,8 @@ module Sidekiq
|
|
44
44
|
end
|
45
45
|
|
46
46
|
get "/" do
|
47
|
-
@redis_info = redis_info.select{ |k, v| REDIS_KEYS.include? k }
|
48
|
-
stats_history = Sidekiq::Stats::History.new((params[
|
47
|
+
@redis_info = redis_info.select { |k, v| REDIS_KEYS.include? k }
|
48
|
+
stats_history = Sidekiq::Stats::History.new((params["days"] || 30).to_i)
|
49
49
|
@processed_history = stats_history.processed
|
50
50
|
@failed_history = stats_history.failed
|
51
51
|
|
@@ -57,14 +57,14 @@ module Sidekiq
|
|
57
57
|
end
|
58
58
|
|
59
59
|
post "/busy" do
|
60
|
-
if params[
|
61
|
-
p = Sidekiq::Process.new(
|
62
|
-
p.quiet! if params[
|
63
|
-
p.stop! if params[
|
60
|
+
if params["identity"]
|
61
|
+
p = Sidekiq::Process.new("identity" => params["identity"])
|
62
|
+
p.quiet! if params["quiet"]
|
63
|
+
p.stop! if params["stop"]
|
64
64
|
else
|
65
65
|
processes.each do |pro|
|
66
|
-
pro.quiet! if params[
|
67
|
-
pro.stop! if params[
|
66
|
+
pro.quiet! if params["quiet"]
|
67
|
+
pro.stop! if params["stop"]
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -82,9 +82,9 @@ module Sidekiq
|
|
82
82
|
|
83
83
|
halt(404) unless @name
|
84
84
|
|
85
|
-
@count = (params[
|
85
|
+
@count = (params["count"] || 25).to_i
|
86
86
|
@queue = Sidekiq::Queue.new(@name)
|
87
|
-
(@current_page, @total_size, @messages) = page("queue:#{@name}", params[
|
87
|
+
(@current_page, @total_size, @messages) = page("queue:#{@name}", params["page"], @count)
|
88
88
|
@messages = @messages.map { |msg| Sidekiq::Job.new(msg, @name) }
|
89
89
|
|
90
90
|
erb(:queue)
|
@@ -98,21 +98,22 @@ module Sidekiq
|
|
98
98
|
|
99
99
|
post "/queues/:name/delete" do
|
100
100
|
name = route_params[:name]
|
101
|
-
Sidekiq::Job.new(params[
|
101
|
+
Sidekiq::Job.new(params["key_val"], name).delete
|
102
102
|
|
103
103
|
redirect_with_query("#{root_path}queues/#{CGI.escape(name)}")
|
104
104
|
end
|
105
105
|
|
106
|
-
get
|
107
|
-
@count = (params[
|
108
|
-
(@current_page, @total_size, @dead) = page("dead", params[
|
106
|
+
get "/morgue" do
|
107
|
+
@count = (params["count"] || 25).to_i
|
108
|
+
(@current_page, @total_size, @dead) = page("dead", params["page"], @count, reverse: true)
|
109
109
|
@dead = @dead.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
|
110
110
|
|
111
111
|
erb(:morgue)
|
112
112
|
end
|
113
113
|
|
114
114
|
get "/morgue/:key" do
|
115
|
-
|
115
|
+
key = route_params[:key]
|
116
|
+
halt(404) unless key
|
116
117
|
|
117
118
|
@dead = Sidekiq::DeadSet.new.fetch(*parse_params(key)).first
|
118
119
|
|
@@ -123,10 +124,10 @@ module Sidekiq
|
|
123
124
|
end
|
124
125
|
end
|
125
126
|
|
126
|
-
post
|
127
|
-
redirect(request.path) unless params[
|
127
|
+
post "/morgue" do
|
128
|
+
redirect(request.path) unless params["key"]
|
128
129
|
|
129
|
-
params[
|
130
|
+
params["key"].each do |key|
|
130
131
|
job = Sidekiq::DeadSet.new.fetch(*parse_params(key)).first
|
131
132
|
retry_or_delete_or_kill job, params if job
|
132
133
|
end
|
@@ -147,7 +148,8 @@ module Sidekiq
|
|
147
148
|
end
|
148
149
|
|
149
150
|
post "/morgue/:key" do
|
150
|
-
|
151
|
+
key = route_params[:key]
|
152
|
+
halt(404) unless key
|
151
153
|
|
152
154
|
job = Sidekiq::DeadSet.new.fetch(*parse_params(key)).first
|
153
155
|
retry_or_delete_or_kill job, params if job
|
@@ -155,9 +157,9 @@ module Sidekiq
|
|
155
157
|
redirect_with_query("#{root_path}morgue")
|
156
158
|
end
|
157
159
|
|
158
|
-
get
|
159
|
-
@count = (params[
|
160
|
-
(@current_page, @total_size, @retries) = page("retry", params[
|
160
|
+
get "/retries" do
|
161
|
+
@count = (params["count"] || 25).to_i
|
162
|
+
(@current_page, @total_size, @retries) = page("retry", params["page"], @count)
|
161
163
|
@retries = @retries.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
|
162
164
|
|
163
165
|
erb(:retries)
|
@@ -173,10 +175,10 @@ module Sidekiq
|
|
173
175
|
end
|
174
176
|
end
|
175
177
|
|
176
|
-
post
|
177
|
-
redirect(request.path) unless params[
|
178
|
+
post "/retries" do
|
179
|
+
redirect(request.path) unless params["key"]
|
178
180
|
|
179
|
-
params[
|
181
|
+
params["key"].each do |key|
|
180
182
|
job = Sidekiq::RetrySet.new.fetch(*parse_params(key)).first
|
181
183
|
retry_or_delete_or_kill job, params if job
|
182
184
|
end
|
@@ -196,6 +198,12 @@ module Sidekiq
|
|
196
198
|
redirect "#{root_path}retries"
|
197
199
|
end
|
198
200
|
|
201
|
+
post "/retries/all/kill" do
|
202
|
+
Sidekiq::RetrySet.new.kill_all
|
203
|
+
|
204
|
+
redirect "#{root_path}retries"
|
205
|
+
end
|
206
|
+
|
199
207
|
post "/retries/:key" do
|
200
208
|
job = Sidekiq::RetrySet.new.fetch(*parse_params(route_params[:key])).first
|
201
209
|
|
@@ -204,9 +212,9 @@ module Sidekiq
|
|
204
212
|
redirect_with_query("#{root_path}retries")
|
205
213
|
end
|
206
214
|
|
207
|
-
get
|
208
|
-
@count = (params[
|
209
|
-
(@current_page, @total_size, @scheduled) = page("schedule", params[
|
215
|
+
get "/scheduled" do
|
216
|
+
@count = (params["count"] || 25).to_i
|
217
|
+
(@current_page, @total_size, @scheduled) = page("schedule", params["page"], @count)
|
210
218
|
@scheduled = @scheduled.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
|
211
219
|
|
212
220
|
erb(:scheduled)
|
@@ -222,10 +230,10 @@ module Sidekiq
|
|
222
230
|
end
|
223
231
|
end
|
224
232
|
|
225
|
-
post
|
226
|
-
redirect(request.path) unless params[
|
233
|
+
post "/scheduled" do
|
234
|
+
redirect(request.path) unless params["key"]
|
227
235
|
|
228
|
-
params[
|
236
|
+
params["key"].each do |key|
|
229
237
|
job = Sidekiq::ScheduledSet.new.fetch(*parse_params(key)).first
|
230
238
|
delete_or_add_queue job, params if job
|
231
239
|
end
|
@@ -234,7 +242,8 @@ module Sidekiq
|
|
234
242
|
end
|
235
243
|
|
236
244
|
post "/scheduled/:key" do
|
237
|
-
|
245
|
+
key = route_params[:key]
|
246
|
+
halt(404) unless key
|
238
247
|
|
239
248
|
job = Sidekiq::ScheduledSet.new.fetch(*parse_params(key)).first
|
240
249
|
delete_or_add_queue job, params if job
|
@@ -242,39 +251,39 @@ module Sidekiq
|
|
242
251
|
redirect_with_query("#{root_path}scheduled")
|
243
252
|
end
|
244
253
|
|
245
|
-
get
|
254
|
+
get "/dashboard/stats" do
|
246
255
|
redirect "#{root_path}stats"
|
247
256
|
end
|
248
257
|
|
249
|
-
get
|
258
|
+
get "/stats" do
|
250
259
|
sidekiq_stats = Sidekiq::Stats.new
|
251
|
-
redis_stats
|
260
|
+
redis_stats = redis_info.select { |k, v| REDIS_KEYS.include? k }
|
252
261
|
json(
|
253
262
|
sidekiq: {
|
254
|
-
processed:
|
255
|
-
failed:
|
256
|
-
busy:
|
257
|
-
processes:
|
258
|
-
enqueued:
|
259
|
-
scheduled:
|
260
|
-
retries:
|
261
|
-
dead:
|
262
|
-
default_latency: sidekiq_stats.default_queue_latency
|
263
|
+
processed: sidekiq_stats.processed,
|
264
|
+
failed: sidekiq_stats.failed,
|
265
|
+
busy: sidekiq_stats.workers_size,
|
266
|
+
processes: sidekiq_stats.processes_size,
|
267
|
+
enqueued: sidekiq_stats.enqueued,
|
268
|
+
scheduled: sidekiq_stats.scheduled_size,
|
269
|
+
retries: sidekiq_stats.retry_size,
|
270
|
+
dead: sidekiq_stats.dead_size,
|
271
|
+
default_latency: sidekiq_stats.default_queue_latency,
|
263
272
|
},
|
264
273
|
redis: redis_stats,
|
265
274
|
server_utc_time: server_utc_time
|
266
275
|
)
|
267
276
|
end
|
268
277
|
|
269
|
-
get
|
278
|
+
get "/stats/queues" do
|
270
279
|
json Sidekiq::Stats::Queues.new.lengths
|
271
280
|
end
|
272
281
|
|
273
282
|
def call(env)
|
274
283
|
action = self.class.match(env)
|
275
|
-
return [404, {"Content-Type" => "text/plain", "X-Cascade" => "pass"
|
284
|
+
return [404, {"Content-Type" => "text/plain", "X-Cascade" => "pass"}, ["Not Found"]] unless action
|
276
285
|
|
277
|
-
resp = catch(:halt)
|
286
|
+
resp = catch(:halt) {
|
278
287
|
app = @klass
|
279
288
|
self.class.run_befores(app, action)
|
280
289
|
begin
|
@@ -284,7 +293,7 @@ module Sidekiq
|
|
284
293
|
end
|
285
294
|
|
286
295
|
resp
|
287
|
-
|
296
|
+
}
|
288
297
|
|
289
298
|
resp = case resp
|
290
299
|
when Array
|
@@ -294,7 +303,7 @@ module Sidekiq
|
|
294
303
|
"Content-Type" => "text/html",
|
295
304
|
"Cache-Control" => "no-cache",
|
296
305
|
"Content-Language" => action.locale,
|
297
|
-
"Content-Security-Policy" => CSP_HEADER
|
306
|
+
"Content-Security-Policy" => CSP_HEADER,
|
298
307
|
}
|
299
308
|
|
300
309
|
[200, headers, [resp]]
|
@@ -307,7 +316,7 @@ module Sidekiq
|
|
307
316
|
resp
|
308
317
|
end
|
309
318
|
|
310
|
-
def self.helpers(mod=nil, &block)
|
319
|
+
def self.helpers(mod = nil, &block)
|
311
320
|
if block_given?
|
312
321
|
WebAction.class_eval(&block)
|
313
322
|
else
|
@@ -315,11 +324,11 @@ module Sidekiq
|
|
315
324
|
end
|
316
325
|
end
|
317
326
|
|
318
|
-
def self.before(path=nil, &block)
|
327
|
+
def self.before(path = nil, &block)
|
319
328
|
befores << [path && Regexp.new("\\A#{path.gsub("*", ".*")}\\z"), block]
|
320
329
|
end
|
321
330
|
|
322
|
-
def self.after(path=nil, &block)
|
331
|
+
def self.after(path = nil, &block)
|
323
332
|
afters << [path && Regexp.new("\\A#{path.gsub("*", ".*")}\\z"), block]
|
324
333
|
end
|
325
334
|
|
@@ -332,8 +341,8 @@ module Sidekiq
|
|
332
341
|
end
|
333
342
|
|
334
343
|
def self.run_hooks(hooks, app, action)
|
335
|
-
hooks.select { |p,_| !p || p =~ action.env[WebRouter::PATH_INFO] }
|
336
|
-
|
344
|
+
hooks.select { |p, _| !p || p =~ action.env[WebRouter::PATH_INFO] }
|
345
|
+
.each { |_, b| action.instance_exec(action.env, app, &b) }
|
337
346
|
end
|
338
347
|
|
339
348
|
def self.befores
|