sidekiq 5.2.5 → 6.0.3

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.

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