mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Merge env based config to top level config and use not only command line options but also RAILS_ENV and RACK_ENV.
This commit is contained in:
parent
86f069cff7
commit
2d6672b7d7
2 changed files with 5 additions and 9 deletions
|
@ -59,12 +59,14 @@ module Sidekiq
|
|||
@code = nil
|
||||
@interrupt_mutex = Mutex.new
|
||||
@interrupted = false
|
||||
@environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
|
||||
end
|
||||
|
||||
def parse(args=ARGV)
|
||||
@code = nil
|
||||
|
||||
cli = parse_options(args)
|
||||
@environment = cli[:environment] if cli[:environment]
|
||||
config = parse_config(cli)
|
||||
options.merge!(config.merge(cli))
|
||||
|
||||
|
@ -118,12 +120,8 @@ module Sidekiq
|
|||
Sidekiq.options
|
||||
end
|
||||
|
||||
def detected_environment
|
||||
options[:environment] ||= ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
|
||||
end
|
||||
|
||||
def boot_system
|
||||
ENV['RACK_ENV'] = ENV['RAILS_ENV'] = detected_environment
|
||||
ENV['RACK_ENV'] = ENV['RAILS_ENV'] = @environment
|
||||
|
||||
raise ArgumentError, "#{options[:require]} does not exist" unless File.exist?(options[:require])
|
||||
|
||||
|
@ -246,9 +244,7 @@ module Sidekiq
|
|||
opts = {}
|
||||
if cli[:config_file] && File.exist?(cli[:config_file])
|
||||
opts = YAML.load(ERB.new(IO.read(cli[:config_file])).result)
|
||||
if env = cli[:environment]
|
||||
opts = opts[env] || opts
|
||||
end
|
||||
opts = opts.merge(opts[@environment]) if opts[@environment].is_a?(Hash)
|
||||
parse_queues opts, opts.delete(:queues) || []
|
||||
end
|
||||
opts
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
:pidfile: /tmp/sidekiq-config-test.pid
|
||||
staging:
|
||||
:verbose: false
|
||||
:require: ./test/fake_env.rb
|
||||
:pidfile: /tmp/sidekiq-config-test.pid
|
||||
:logfile: /tmp/sidekiq.log
|
||||
:concurrency: 50
|
||||
:queues:
|
||||
|
|
Loading…
Add table
Reference in a new issue