Skip to content

Commit

Permalink
Merge pull request sidekiq#2352 from TeachstoneLLC/ms/better_configur…
Browse files Browse the repository at this point in the history
…ation_file_parameter_validation

Validate parameters in config file
  • Loading branch information
mperham committed May 15, 2015
2 parents eb38086 + d8e6de8 commit a48e7be
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/sidekiq/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,25 @@ def validate!
logger.info @parser
die(1)
end

# Ensure numeric option values are numbers and fall in reasonable ranges
[:concurrency, :timeout].each do |option|
next unless options.has_key?(option)

unless options[option].is_a? Integer
raise(
ArgumentError,
%{"#{option}": "#{options[option]}" is not a valid integer}
)
end

if options[option] <= 0
raise(
ArgumentError,
%{"#{option}": must be > 0 (current value: #{options[option]})}
)
end
end
end

def parse_options(argv)
Expand Down

0 comments on commit a48e7be

Please sign in to comment.