mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Use options from the config file properly. Fixes #764
This commit is contained in:
parent
3f7346e6c1
commit
6ebd5004bd
1 changed files with 20 additions and 14 deletions
|
@ -17,37 +17,37 @@ module Puma
|
||||||
@argv = argv
|
@argv = argv
|
||||||
@stdout = stdout
|
@stdout = stdout
|
||||||
@stderr = stderr
|
@stderr = stderr
|
||||||
@options = {}
|
@cli_options = {}
|
||||||
|
|
||||||
opts = OptionParser.new do |o|
|
opts = OptionParser.new do |o|
|
||||||
o.banner = "Usage: pumactl (-p PID | -P pidfile | -S status_file | -C url -T token | -F config.rb) (#{COMMANDS.join("|")})"
|
o.banner = "Usage: pumactl (-p PID | -P pidfile | -S status_file | -C url -T token | -F config.rb) (#{COMMANDS.join("|")})"
|
||||||
|
|
||||||
o.on "-S", "--state PATH", "Where the state file to use is" do |arg|
|
o.on "-S", "--state PATH", "Where the state file to use is" do |arg|
|
||||||
@options[:state] = arg
|
@cli_options[:state] = arg
|
||||||
end
|
end
|
||||||
|
|
||||||
o.on "-Q", "--quiet", "Not display messages" do |arg|
|
o.on "-Q", "--quiet", "Not display messages" do |arg|
|
||||||
@options[:quiet_flag] = true
|
@cli_options[:quiet_flag] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
o.on "-P", "--pidfile PATH", "Pid file" do |arg|
|
o.on "-P", "--pidfile PATH", "Pid file" do |arg|
|
||||||
@options[:pidfile] = arg
|
@cli_options[:pidfile] = arg
|
||||||
end
|
end
|
||||||
|
|
||||||
o.on "-p", "--pid PID", "Pid" do |arg|
|
o.on "-p", "--pid PID", "Pid" do |arg|
|
||||||
@options[:pid] = arg.to_i
|
@cli_options[:pid] = arg.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
o.on "-C", "--control-url URL", "The bind url to use for the control server" do |arg|
|
o.on "-C", "--control-url URL", "The bind url to use for the control server" do |arg|
|
||||||
@options[:control_url] = arg
|
@cli_options[:control_url] = arg
|
||||||
end
|
end
|
||||||
|
|
||||||
o.on "-T", "--control-token TOKEN", "The token to use as authentication for the control server" do |arg|
|
o.on "-T", "--control-token TOKEN", "The token to use as authentication for the control server" do |arg|
|
||||||
@options[:control_auth_token] = arg
|
@cli_options[:control_auth_token] = arg
|
||||||
end
|
end
|
||||||
|
|
||||||
o.on "-F", "--config-file PATH", "Puma config script" do |arg|
|
o.on "-F", "--config-file PATH", "Puma config script" do |arg|
|
||||||
@options[:config_file] = arg
|
@cli_options[:config_file] = arg
|
||||||
end
|
end
|
||||||
|
|
||||||
o.on_tail("-H", "--help", "Show this message") do
|
o.on_tail("-H", "--help", "Show this message") do
|
||||||
|
@ -64,18 +64,24 @@ module Puma
|
||||||
opts.order!(argv) { |a| opts.terminate a }
|
opts.order!(argv) { |a| opts.terminate a }
|
||||||
|
|
||||||
command = argv.shift
|
command = argv.shift
|
||||||
@options[:command] = command if command
|
@cli_options[:command] = command if command
|
||||||
|
|
||||||
unless @options[:config_file] == '-'
|
@options = nil
|
||||||
if @options[:config_file].nil? and File.exist?('config/puma.rb')
|
|
||||||
@options[:config_file] = 'config/puma.rb'
|
unless @cli_options[:config_file] == '-'
|
||||||
|
if @cli_options[:config_file].nil? and File.exist?('config/puma.rb')
|
||||||
|
@cli_options[:config_file] = 'config/puma.rb'
|
||||||
end
|
end
|
||||||
|
|
||||||
if @options[:config_file]
|
if @cli_options[:config_file]
|
||||||
Puma::Configuration.new(@options).load
|
config = Puma::Configuration.new(@cli_options)
|
||||||
|
config.load
|
||||||
|
@options = config.options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@options ||= @cli_options
|
||||||
|
|
||||||
# check present of command
|
# check present of command
|
||||||
unless @options[:command]
|
unless @options[:command]
|
||||||
raise "Available commands: #{COMMANDS.join(", ")}"
|
raise "Available commands: #{COMMANDS.join(", ")}"
|
||||||
|
|
Loading…
Reference in a new issue