sidekiq 5.2.4 → 6.0.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/.circleci/config.yml +82 -0
- data/.gitignore +0 -2
- data/.standard.yml +20 -0
- data/6.0-Upgrade.md +72 -0
- data/COMM-LICENSE +11 -9
- data/Changes.md +129 -0
- data/Ent-2.0-Upgrade.md +37 -0
- data/Ent-Changes.md +32 -1
- data/Gemfile +12 -17
- data/Gemfile.lock +196 -0
- data/Pro-5.0-Upgrade.md +25 -0
- data/Pro-Changes.md +26 -2
- data/README.md +18 -31
- data/Rakefile +5 -4
- data/bin/sidekiqload +33 -25
- data/bin/sidekiqmon +8 -0
- data/lib/generators/sidekiq/templates/worker_test.rb.erb +1 -1
- data/lib/generators/sidekiq/worker_generator.rb +20 -12
- data/lib/sidekiq.rb +62 -43
- data/lib/sidekiq/api.rb +196 -175
- data/lib/sidekiq/cli.rb +118 -178
- data/lib/sidekiq/client.rb +51 -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 +11 -12
- data/lib/sidekiq/job_logger.rb +45 -7
- data/lib/sidekiq/job_retry.rb +67 -58
- data/lib/sidekiq/launcher.rb +57 -51
- data/lib/sidekiq/logger.rb +165 -0
- data/lib/sidekiq/manager.rb +7 -9
- data/lib/sidekiq/middleware/chain.rb +14 -4
- data/lib/sidekiq/middleware/i18n.rb +5 -7
- data/lib/sidekiq/monitor.rb +148 -0
- data/lib/sidekiq/paginator.rb +18 -14
- data/lib/sidekiq/processor.rb +96 -66
- data/lib/sidekiq/rails.rb +23 -29
- data/lib/sidekiq/redis_connection.rb +31 -37
- data/lib/sidekiq/scheduled.rb +28 -29
- data/lib/sidekiq/testing.rb +34 -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 +63 -64
- data/lib/sidekiq/web/helpers.rb +92 -68
- data/lib/sidekiq/web/router.rb +17 -14
- data/lib/sidekiq/worker.rb +129 -97
- data/sidekiq.gemspec +16 -16
- data/web/assets/javascripts/dashboard.js +4 -23
- data/web/assets/stylesheets/application-dark.css +125 -0
- data/web/assets/stylesheets/application.css +9 -0
- data/web/assets/stylesheets/bootstrap.css +1 -1
- data/web/locales/ja.yml +2 -1
- data/web/views/_job_info.erb +2 -1
- data/web/views/busy.erb +4 -1
- data/web/views/dead.erb +2 -2
- data/web/views/layout.erb +1 -0
- data/web/views/morgue.erb +4 -1
- data/web/views/queue.erb +10 -1
- data/web/views/queues.erb +1 -1
- data/web/views/retries.erb +4 -1
- data/web/views/retry.erb +2 -2
- data/web/views/scheduled.erb +4 -1
- metadata +20 -30
- data/.travis.yml +0 -17
- data/Appraisals +0 -9
- data/bin/sidekiqctl +0 -237
- data/gemfiles/rails_4.gemfile +0 -31
- data/gemfiles/rails_5.gemfile +0 -31
- 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/cli.rb
CHANGED
@@ -1,29 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
$stdout.sync = true
|
3
4
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
5
|
+
require "yaml"
|
6
|
+
require "singleton"
|
7
|
+
require "optparse"
|
8
|
+
require "erb"
|
9
|
+
require "fileutils"
|
9
10
|
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
11
|
+
require "sidekiq"
|
12
|
+
require "sidekiq/launcher"
|
13
|
+
require "sidekiq/util"
|
13
14
|
|
14
15
|
module Sidekiq
|
15
16
|
class CLI
|
16
17
|
include Util
|
17
18
|
include Singleton unless $TESTING
|
18
19
|
|
19
|
-
PROCTITLES = [
|
20
|
-
proc { 'sidekiq' },
|
21
|
-
proc { Sidekiq::VERSION },
|
22
|
-
proc { |me, data| data['tag'] },
|
23
|
-
proc { |me, data| "[#{Processor::WORKER_STATE.size} of #{data['concurrency']} busy]" },
|
24
|
-
proc { |me, data| "stopping" if me.stopping? },
|
25
|
-
]
|
26
|
-
|
27
20
|
attr_accessor :launcher
|
28
21
|
attr_accessor :environment
|
29
22
|
|
@@ -41,27 +34,19 @@ module Sidekiq
|
|
41
34
|
# global process state irreversibly. PRs which improve the
|
42
35
|
# test coverage of Sidekiq::CLI are welcomed.
|
43
36
|
def run
|
44
|
-
daemonize if options[:daemon]
|
45
|
-
write_pid
|
46
37
|
boot_system
|
47
|
-
|
48
|
-
|
49
|
-
self_read, self_write = IO.pipe
|
50
|
-
sigs = %w(INT TERM TTIN TSTP)
|
51
|
-
# USR1 and USR2 don't work on the JVM
|
52
|
-
if !jruby?
|
53
|
-
sigs << 'USR1'
|
54
|
-
sigs << 'USR2'
|
38
|
+
if environment == "development" && $stdout.tty? && Sidekiq.log_formatter.is_a?(Sidekiq::Logger::Formatters::Pretty)
|
39
|
+
print_banner
|
55
40
|
end
|
56
41
|
|
42
|
+
self_read, self_write = IO.pipe
|
43
|
+
sigs = %w[INT TERM TTIN TSTP]
|
57
44
|
sigs.each do |sig|
|
58
|
-
|
59
|
-
|
60
|
-
self_write.write("#{sig}\n")
|
61
|
-
end
|
62
|
-
rescue ArgumentError
|
63
|
-
puts "Signal #{sig} not supported"
|
45
|
+
trap sig do
|
46
|
+
self_write.puts(sig)
|
64
47
|
end
|
48
|
+
rescue ArgumentError
|
49
|
+
puts "Signal #{sig} not supported"
|
65
50
|
end
|
66
51
|
|
67
52
|
logger.info "Running in #{RUBY_DESCRIPTION}"
|
@@ -70,9 +55,8 @@ module Sidekiq
|
|
70
55
|
|
71
56
|
# touch the connection pool so it is created before we
|
72
57
|
# fire startup and start multithreading.
|
73
|
-
ver = Sidekiq.redis_info[
|
74
|
-
raise "You are using Redis v#{ver}, Sidekiq requires Redis
|
75
|
-
logger.warn "Sidekiq 6.0 will require Redis 4.0+, you are using Redis v#{ver}" if ver < '4'
|
58
|
+
ver = Sidekiq.redis_info["redis_version"]
|
59
|
+
raise "You are using Redis v#{ver}, Sidekiq requires Redis v4.0.0 or greater" if ver < "4"
|
76
60
|
|
77
61
|
# Since the user can pass us a connection pool explicitly in the initializer, we
|
78
62
|
# need to verify the size is large enough or else Sidekiq's performance is dramatically slowed.
|
@@ -90,15 +74,15 @@ module Sidekiq
|
|
90
74
|
# Starting here the process will now have multiple threads running.
|
91
75
|
fire_event(:startup, reverse: false, reraise: true)
|
92
76
|
|
93
|
-
logger.debug { "Client Middleware: #{Sidekiq.client_middleware.map(&:klass).join(
|
94
|
-
logger.debug { "Server Middleware: #{Sidekiq.server_middleware.map(&:klass).join(
|
77
|
+
logger.debug { "Client Middleware: #{Sidekiq.client_middleware.map(&:klass).join(", ")}" }
|
78
|
+
logger.debug { "Server Middleware: #{Sidekiq.server_middleware.map(&:klass).join(", ")}" }
|
95
79
|
|
96
80
|
launch(self_read)
|
97
81
|
end
|
98
82
|
|
99
83
|
def launch(self_read)
|
100
|
-
if
|
101
|
-
logger.info
|
84
|
+
if environment == "development" && $stdout.tty?
|
85
|
+
logger.info "Starting processing, hit Ctrl-C to stop"
|
102
86
|
end
|
103
87
|
|
104
88
|
@launcher = Sidekiq::Launcher.new(options)
|
@@ -106,60 +90,70 @@ module Sidekiq
|
|
106
90
|
begin
|
107
91
|
launcher.run
|
108
92
|
|
109
|
-
while readable_io = IO.select([self_read])
|
93
|
+
while (readable_io = IO.select([self_read]))
|
110
94
|
signal = readable_io.first[0].gets.strip
|
111
95
|
handle_signal(signal)
|
112
96
|
end
|
113
97
|
rescue Interrupt
|
114
|
-
logger.info
|
98
|
+
logger.info "Shutting down"
|
115
99
|
launcher.stop
|
116
|
-
# Explicitly exit so busy Processor threads can't block
|
117
|
-
# process shutdown.
|
118
100
|
logger.info "Bye!"
|
101
|
+
|
102
|
+
# Explicitly exit so busy Processor threads won't block process shutdown.
|
103
|
+
#
|
104
|
+
# NB: slow at_exit handlers will prevent a timely exit if they take
|
105
|
+
# a while to run. If Sidekiq is getting here but the process isn't exiting,
|
106
|
+
# use the TTIN signal to determine where things are stuck.
|
119
107
|
exit(0)
|
120
108
|
end
|
121
109
|
end
|
122
110
|
|
111
|
+
def self.w
|
112
|
+
"\e[37m"
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.r
|
116
|
+
"\e[31m"
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.b
|
120
|
+
"\e[30m"
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.reset
|
124
|
+
"\e[0m"
|
125
|
+
end
|
126
|
+
|
123
127
|
def self.banner
|
124
|
-
%
|
125
|
-
m,
|
126
|
-
`$b
|
127
|
-
.ss, $$: .,d$
|
128
|
-
`$$P,d$P' .,md$P"'
|
129
|
-
,$$$$$
|
130
|
-
.d
|
131
|
-
$$^' `"
|
132
|
-
$: ,$$:
|
133
|
-
`b :$$
|
134
|
-
$$:
|
135
|
-
$$ |____/|_
|
136
|
-
.d$$
|
137
|
-
}
|
128
|
+
%{
|
129
|
+
#{w} m,
|
130
|
+
#{w} `$b
|
131
|
+
#{w} .ss, $$: .,d$
|
132
|
+
#{w} `$$P,d$P' .,md$P"'
|
133
|
+
#{w} ,$$$$$b#{b}/#{w}md$$$P^'
|
134
|
+
#{w} .d$$$$$$#{b}/#{w}$$$P'
|
135
|
+
#{w} $$^' `"#{b}/#{w}$$$' #{r}____ _ _ _ _
|
136
|
+
#{w} $: ,$$: #{r} / ___|(_) __| | ___| | _(_) __ _
|
137
|
+
#{w} `b :$$ #{r} \\___ \\| |/ _` |/ _ \\ |/ / |/ _` |
|
138
|
+
#{w} $$: #{r} ___) | | (_| | __/ <| | (_| |
|
139
|
+
#{w} $$ #{r}|____/|_|\\__,_|\\___|_|\\_\\_|\\__, |
|
140
|
+
#{w} .d$$ #{r} |_|
|
141
|
+
#{reset}}
|
138
142
|
end
|
139
143
|
|
140
144
|
SIGNAL_HANDLERS = {
|
141
145
|
# Ctrl-C in terminal
|
142
|
-
|
146
|
+
"INT" => ->(cli) { raise Interrupt },
|
143
147
|
# TERM is the signal that Sidekiq must exit.
|
144
148
|
# Heroku sends TERM and then waits 30 seconds for process to exit.
|
145
|
-
|
146
|
-
|
147
|
-
Sidekiq.logger.info "Received USR1, no longer accepting new work"
|
148
|
-
cli.launcher.quiet
|
149
|
-
},
|
150
|
-
'TSTP' => ->(cli) {
|
149
|
+
"TERM" => ->(cli) { raise Interrupt },
|
150
|
+
"TSTP" => ->(cli) {
|
151
151
|
Sidekiq.logger.info "Received TSTP, no longer accepting new work"
|
152
152
|
cli.launcher.quiet
|
153
153
|
},
|
154
|
-
|
155
|
-
if Sidekiq.options[:logfile]
|
156
|
-
Sidekiq.logger.info "Received USR2, reopening log file"
|
157
|
-
Sidekiq::Logging.reopen_logs
|
158
|
-
end
|
159
|
-
},
|
160
|
-
'TTIN' => ->(cli) {
|
154
|
+
"TTIN" => ->(cli) {
|
161
155
|
Thread.list.each do |thread|
|
162
|
-
Sidekiq.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread
|
156
|
+
Sidekiq.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread.name}"
|
163
157
|
if thread.backtrace
|
164
158
|
Sidekiq.logger.warn thread.backtrace.join("\n")
|
165
159
|
else
|
@@ -168,59 +162,31 @@ module Sidekiq
|
|
168
162
|
end
|
169
163
|
},
|
170
164
|
}
|
165
|
+
UNHANDLED_SIGNAL_HANDLER = ->(cli) { Sidekiq.logger.info "No signal handler registered, ignoring" }
|
166
|
+
SIGNAL_HANDLERS.default = UNHANDLED_SIGNAL_HANDLER
|
171
167
|
|
172
168
|
def handle_signal(sig)
|
173
169
|
Sidekiq.logger.debug "Got #{sig} signal"
|
174
|
-
|
175
|
-
if handy
|
176
|
-
handy.call(self)
|
177
|
-
else
|
178
|
-
Sidekiq.logger.info { "No signal handler for #{sig}" }
|
179
|
-
end
|
170
|
+
SIGNAL_HANDLERS[sig].call(self)
|
180
171
|
end
|
181
172
|
|
182
173
|
private
|
183
174
|
|
184
175
|
def print_banner
|
185
|
-
puts "\e[
|
176
|
+
puts "\e[31m"
|
186
177
|
puts Sidekiq::CLI.banner
|
187
178
|
puts "\e[0m"
|
188
179
|
end
|
189
180
|
|
190
|
-
def daemonize
|
191
|
-
raise ArgumentError, "You really should set a logfile if you're going to daemonize" unless options[:logfile]
|
192
|
-
|
193
|
-
files_to_reopen = ObjectSpace.each_object(File).reject { |f| f.closed? }
|
194
|
-
::Process.daemon(true, true)
|
195
|
-
|
196
|
-
files_to_reopen.each do |file|
|
197
|
-
begin
|
198
|
-
file.reopen file.path, "a+"
|
199
|
-
file.sync = true
|
200
|
-
rescue ::Exception
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
[$stdout, $stderr].each do |io|
|
205
|
-
File.open(options[:logfile], 'ab') do |f|
|
206
|
-
io.reopen(f)
|
207
|
-
end
|
208
|
-
io.sync = true
|
209
|
-
end
|
210
|
-
$stdin.reopen('/dev/null')
|
211
|
-
|
212
|
-
initialize_logger
|
213
|
-
end
|
214
|
-
|
215
181
|
def set_environment(cli_env)
|
216
|
-
@environment = cli_env || ENV[
|
182
|
+
@environment = cli_env || ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
|
217
183
|
end
|
218
184
|
|
219
185
|
def symbolize_keys_deep!(hash)
|
220
186
|
hash.keys.each do |k|
|
221
187
|
symkey = k.respond_to?(:to_sym) ? k.to_sym : k
|
222
188
|
hash[symkey] = hash.delete k
|
223
|
-
symbolize_keys_deep! hash[symkey] if hash[symkey].
|
189
|
+
symbolize_keys_deep! hash[symkey] if hash[symkey].is_a? Hash
|
224
190
|
end
|
225
191
|
end
|
226
192
|
|
@@ -235,22 +201,27 @@ module Sidekiq
|
|
235
201
|
|
236
202
|
# check config file presence
|
237
203
|
if opts[:config_file]
|
238
|
-
|
204
|
+
unless File.exist?(opts[:config_file])
|
239
205
|
raise ArgumentError, "No such file #{opts[:config_file]}"
|
240
206
|
end
|
241
207
|
else
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
208
|
+
config_dir = if File.directory?(opts[:require].to_s)
|
209
|
+
File.join(opts[:require], "config")
|
210
|
+
else
|
211
|
+
File.join(options[:require], "config")
|
212
|
+
end
|
213
|
+
|
214
|
+
%w[sidekiq.yml sidekiq.yml.erb].each do |config_file|
|
215
|
+
path = File.join(config_dir, config_file)
|
216
|
+
opts[:config_file] ||= path if File.exist?(path)
|
247
217
|
end
|
248
218
|
end
|
249
219
|
|
250
220
|
# parse config file options
|
251
221
|
opts = parse_config(opts[:config_file]).merge(opts) if opts[:config_file]
|
252
222
|
|
253
|
-
|
223
|
+
# set defaults
|
224
|
+
opts[:queues] = ["default"] if opts[:queues].nil? || opts[:queues].empty?
|
254
225
|
opts[:strict] = true if opts[:strict].nil?
|
255
226
|
opts[:concurrency] = Integer(ENV["RAILS_MAX_THREADS"]) if opts[:concurrency].nil? && ENV["RAILS_MAX_THREADS"]
|
256
227
|
|
@@ -263,23 +234,14 @@ module Sidekiq
|
|
263
234
|
end
|
264
235
|
|
265
236
|
def boot_system
|
266
|
-
ENV[
|
237
|
+
ENV["RACK_ENV"] = ENV["RAILS_ENV"] = environment
|
267
238
|
|
268
239
|
if File.directory?(options[:require])
|
269
|
-
require
|
270
|
-
if ::Rails::VERSION::MAJOR <
|
240
|
+
require "rails"
|
241
|
+
if ::Rails::VERSION::MAJOR < 5
|
271
242
|
raise "Sidekiq no longer supports this version of Rails"
|
272
|
-
elsif ::Rails::VERSION::MAJOR == 4
|
273
|
-
# Painful contortions, see 1791 for discussion
|
274
|
-
# No autoloading, we want to force eager load for everything.
|
275
|
-
require File.expand_path("#{options[:require]}/config/application.rb")
|
276
|
-
::Rails::Application.initializer "sidekiq.eager_load" do
|
277
|
-
::Rails.application.config.eager_load = true
|
278
|
-
end
|
279
|
-
require 'sidekiq/rails'
|
280
|
-
require File.expand_path("#{options[:require]}/config/environment.rb")
|
281
243
|
else
|
282
|
-
require
|
244
|
+
require "sidekiq/rails"
|
283
245
|
require File.expand_path("#{options[:require]}/config/environment.rb")
|
284
246
|
end
|
285
247
|
options[:tag] ||= default_tag
|
@@ -291,8 +253,9 @@ module Sidekiq
|
|
291
253
|
def default_tag
|
292
254
|
dir = ::Rails.root
|
293
255
|
name = File.basename(dir)
|
294
|
-
|
295
|
-
|
256
|
+
prevdir = File.dirname(dir) # Capistrano release directory?
|
257
|
+
if name.to_i != 0 && prevdir
|
258
|
+
if File.basename(prevdir) == "releases"
|
296
259
|
return File.basename(File.dirname(prevdir))
|
297
260
|
end
|
298
261
|
end
|
@@ -301,9 +264,9 @@ module Sidekiq
|
|
301
264
|
|
302
265
|
def validate!
|
303
266
|
if !File.exist?(options[:require]) ||
|
304
|
-
|
267
|
+
(File.directory?(options[:require]) && !File.exist?("#{options[:require]}/config/application.rb"))
|
305
268
|
logger.info "=================================================================="
|
306
|
-
logger.info " Please point
|
269
|
+
logger.info " Please point Sidekiq to a Rails application or a Ruby file "
|
307
270
|
logger.info " to load your worker classes with -r [DIR|FILE]."
|
308
271
|
logger.info "=================================================================="
|
309
272
|
logger.info @parser
|
@@ -311,47 +274,45 @@ module Sidekiq
|
|
311
274
|
end
|
312
275
|
|
313
276
|
[:concurrency, :timeout].each do |opt|
|
314
|
-
raise ArgumentError, "#{opt}: #{options[opt]} is not a valid value" if options.
|
277
|
+
raise ArgumentError, "#{opt}: #{options[opt]} is not a valid value" if options.key?(opt) && options[opt].to_i <= 0
|
315
278
|
end
|
316
279
|
end
|
317
280
|
|
318
281
|
def parse_options(argv)
|
319
282
|
opts = {}
|
283
|
+
@parser = option_parser(opts)
|
284
|
+
@parser.parse!(argv)
|
285
|
+
opts
|
286
|
+
end
|
320
287
|
|
321
|
-
|
322
|
-
|
288
|
+
def option_parser(opts)
|
289
|
+
parser = OptionParser.new { |o|
|
290
|
+
o.on "-c", "--concurrency INT", "processor threads to use" do |arg|
|
323
291
|
opts[:concurrency] = Integer(arg)
|
324
292
|
end
|
325
293
|
|
326
|
-
o.on
|
327
|
-
|
328
|
-
puts "WARNING: Daemonization mode will be removed in Sidekiq 6.0, see #4045. Please use a proper process supervisor to start and manage your services"
|
294
|
+
o.on "-d", "--daemon", "Daemonize process" do |arg|
|
295
|
+
puts "ERROR: Daemonization mode was removed in Sidekiq 6.0, please use a proper process supervisor to start and manage your services"
|
329
296
|
end
|
330
297
|
|
331
|
-
o.on
|
298
|
+
o.on "-e", "--environment ENV", "Application environment" do |arg|
|
332
299
|
opts[:environment] = arg
|
333
300
|
end
|
334
301
|
|
335
|
-
o.on
|
302
|
+
o.on "-g", "--tag TAG", "Process tag for procline" do |arg|
|
336
303
|
opts[:tag] = arg
|
337
304
|
end
|
338
305
|
|
339
|
-
# this index remains here for backwards compatibility but none of the Sidekiq
|
340
|
-
# family use this value anymore. it was used by Pro's original reliable_fetch.
|
341
|
-
o.on '-i', '--index INT', "unique process index on this machine" do |arg|
|
342
|
-
opts[:index] = Integer(arg.match(/\d+/)[0])
|
343
|
-
end
|
344
|
-
|
345
306
|
o.on "-q", "--queue QUEUE[,WEIGHT]", "Queues to process with optional weights" do |arg|
|
346
307
|
queue, weight = arg.split(",")
|
347
308
|
parse_queue opts, queue, weight
|
348
309
|
end
|
349
310
|
|
350
|
-
o.on
|
311
|
+
o.on "-r", "--require [PATH|DIR]", "Location of Rails application with workers or file to require" do |arg|
|
351
312
|
opts[:require] = arg
|
352
313
|
end
|
353
314
|
|
354
|
-
o.on
|
315
|
+
o.on "-t", "--timeout NUM", "Shutdown timeout" do |arg|
|
355
316
|
opts[:timeout] = Integer(arg)
|
356
317
|
end
|
357
318
|
|
@@ -359,52 +320,37 @@ module Sidekiq
|
|
359
320
|
opts[:verbose] = arg
|
360
321
|
end
|
361
322
|
|
362
|
-
o.on
|
323
|
+
o.on "-C", "--config PATH", "path to YAML config file" do |arg|
|
363
324
|
opts[:config_file] = arg
|
364
325
|
end
|
365
326
|
|
366
|
-
o.on
|
367
|
-
|
368
|
-
puts "WARNING: Logfile redirection will be removed in Sidekiq 6.0, see #4045. Sidekiq will only log to STDOUT"
|
327
|
+
o.on "-L", "--logfile PATH", "path to writable logfile" do |arg|
|
328
|
+
puts "ERROR: Logfile redirection was removed in Sidekiq 6.0, Sidekiq will only log to STDOUT"
|
369
329
|
end
|
370
330
|
|
371
|
-
o.on
|
372
|
-
|
373
|
-
puts "WARNING: PID file creation will be removed in Sidekiq 6.0, see #4045. Please use a proper process supervisor to start and manage your services"
|
331
|
+
o.on "-P", "--pidfile PATH", "path to pidfile" do |arg|
|
332
|
+
puts "ERROR: PID file creation was removed in Sidekiq 6.0, please use a proper process supervisor to start and manage your services"
|
374
333
|
end
|
375
334
|
|
376
|
-
o.on
|
335
|
+
o.on "-V", "--version", "Print version and exit" do |arg|
|
377
336
|
puts "Sidekiq #{Sidekiq::VERSION}"
|
378
337
|
die(0)
|
379
338
|
end
|
380
|
-
|
339
|
+
}
|
381
340
|
|
382
|
-
|
383
|
-
|
384
|
-
logger.info
|
341
|
+
parser.banner = "sidekiq [options]"
|
342
|
+
parser.on_tail "-h", "--help", "Show help" do
|
343
|
+
logger.info parser
|
385
344
|
die 1
|
386
345
|
end
|
387
346
|
|
388
|
-
|
389
|
-
|
390
|
-
opts
|
347
|
+
parser
|
391
348
|
end
|
392
349
|
|
393
350
|
def initialize_logger
|
394
|
-
Sidekiq::Logging.initialize_logger(options[:logfile]) if options[:logfile]
|
395
|
-
|
396
351
|
Sidekiq.logger.level = ::Logger::DEBUG if options[:verbose]
|
397
352
|
end
|
398
353
|
|
399
|
-
def write_pid
|
400
|
-
if path = options[:pidfile]
|
401
|
-
pidfile = File.expand_path(path)
|
402
|
-
File.open(pidfile, 'w') do |f|
|
403
|
-
f.puts ::Process.pid
|
404
|
-
end
|
405
|
-
end
|
406
|
-
end
|
407
|
-
|
408
354
|
def parse_config(path)
|
409
355
|
opts = YAML.load(ERB.new(File.read(path)).result) || {}
|
410
356
|
|
@@ -417,12 +363,6 @@ module Sidekiq
|
|
417
363
|
opts = opts.merge(opts.delete(environment.to_sym) || {})
|
418
364
|
parse_queues(opts, opts.delete(:queues) || [])
|
419
365
|
|
420
|
-
ns = opts.delete(:namespace)
|
421
|
-
if ns
|
422
|
-
# logger hasn't been initialized yet, puts is all we have.
|
423
|
-
puts("namespace should be set in your ruby initializer, is ignored in config file")
|
424
|
-
puts("config.redis = { :url => ..., :namespace => '#{ns}' }")
|
425
|
-
end
|
426
366
|
opts
|
427
367
|
end
|
428
368
|
|