Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look for config file at ./config/sidekiq.yml by default (if no -r flag provided) #4076

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/sidekiq/cli.rb
Expand Up @@ -238,12 +238,14 @@ def setup_options(args)
if opts[:config_file] && !File.exist?(opts[:config_file])
raise ArgumentError, "No such file #{opts[:config_file]}"
end
elsif opts[:require] && File.directory?(opts[:require])
%w[config/sidekiq.yml config/sidekiq.yml.erb].each do |filename|
path = File.expand_path(filename, opts[:require])
opts[:config_file] ||= path if File.exist?(path)
end
else
if opts[:require] && File.directory?(opts[:require])
%w[config/sidekiq.yml config/sidekiq.yml.erb].each do |filename|
path = File.expand_path(filename, opts[:require])
opts[:config_file] ||= path if File.exist?(path)
end
%w[config/sidekiq.yml config/sidekiq.yml.erb].each do |filename|
opts[:config_file] ||= filename if File.exist?(filename)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That shouldn't work as far as #parse_config expects an absolute path. Does it make sense?

end
end

Expand Down
9 changes: 9 additions & 0 deletions test/test_cli.rb
Expand Up @@ -254,6 +254,15 @@ class TestCLI < Minitest::Test
assert_equal 25, Sidekiq.options[:concurrency]
end
end

describe 'when no requirement path is provided' do
it 'tries ./config/sidekiq.yml' do
Dir.chdir("test/dummy") do
@cli.parse(%w[sidekiq])
assert_equal 'config/sidekiq.yml', Sidekiq.options[:config_file]
end
end
end
end
end
end
Expand Down