def setup_options
@options = {
:min_threads => 0,
:max_threads => 16,
:quiet => false,
:debug => false,
:binds => [],
:workers => 0,
:daemon => false,
:worker_boot => []
}
@parser = OptionParser.new do |o|
o.on "-b", "--bind URI", "URI to bind to (tcp://, unix://, ssl://)" do |arg|
@options[:binds] << arg
end
o.on "-C", "--config PATH", "Load PATH as a config file" do |arg|
@options[:config_file] = arg
end
o.on "--control URL", "The bind url to use for the control server",
"Use 'auto' to use temp unix server" do |arg|
if arg
@options[:control_url] = arg
elsif jruby?
unsupported "No default url available on JRuby"
end
end
o.on "--control-token TOKEN",
"The token to use as authentication for the control server" do |arg|
@options[:control_auth_token] = arg
end
o.on "-d", "--daemon", "Daemonize the server into the background" do
@options[:daemon] = true
@options[:quiet] = true
end
o.on "--debug", "Log lowlevel debugging information" do
@options[:debug] = true
end
o.on "--dir DIR", "Change to DIR before starting" do |d|
@options[:directory] = d.to_s
@options[:worker_directory] = d.to_s
end
o.on "-e", "--environment ENVIRONMENT",
"The environment to run the Rack app on (default development)" do |arg|
@options[:environment] = arg
end
o.on "-I", "--include PATH", "Specify $LOAD_PATH directories" do |arg|
$LOAD_PATH.unshift(*arg.split(':'))
end
o.on "-p", "--port PORT", "Define the TCP port to bind to",
"Use -b for more advanced options" do |arg|
@options[:binds] << "tcp://#{Configuration::DefaultTCPHost}:#{arg}"
end
o.on "--pidfile PATH", "Use PATH as a pidfile" do |arg|
@options[:pidfile] = arg
end
o.on "--preload", "Preload the app. Cluster mode only" do
@options[:preload_app] = true
end
o.on "-q", "--quiet", "Quiet down the output" do
@options[:quiet] = true
end
o.on "-R", "--restart-cmd CMD",
"The puma command to run during a hot restart",
"Default: inferred" do |cmd|
@options[:restart_cmd] = cmd
end
o.on "-S", "--state PATH", "Where to store the state details" do |arg|
@options[:state] = arg
end
o.on '-t', '--threads INT', "min:max threads to use (default 0:16)" do |arg|
min, max = arg.split(":")
if max
@options[:min_threads] = min
@options[:max_threads] = max
else
@options[:min_threads] = 0
@options[:max_threads] = arg
end
end
o.on "-V", "--version", "Print the version information" do
puts "puma version #{Puma::Const::VERSION}"
exit 1
end
o.on "-w", "--workers COUNT",
"Activate cluster mode: How many worker processes to create" do |arg|
@options[:workers] = arg.to_i
end
end
@parser.banner = "puma <options> <rackup file>"
@parser.on_tail "-h", "--help", "Show help" do
log @parser
exit 1
end
end