-
Notifications
You must be signed in to change notification settings - Fork 507
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
Allow padrino start to take handler specific options #1452
Conversation
to pass options to the rack handler. For instance, with `puma` you can now do: `bundle exec padrino s -O Threads=3:16` and the server will start with 3 to 16 threads. This implementation follows the same syntax that [rackup](https://github.com/rack/rack/blob/master/lib/rack/server.rb\#L100) uses for compatibility. Also implemented --server_options to print out the supported options for the selected handler (application server). This has been requested a couple of times, the latest in #1451. I'd still recommend people to run their applications through the application server directly -e.g., puma, unicorn, thin...- instead of using this but it might come in handy for development.
@@ -31,6 +31,7 @@ def self.start(app, opts={}) | |||
FileUtils.mkdir_p(File.dirname(options[:pid])) | |||
end | |||
options[:server] = detect_rack_handler if options[:server].blank? | |||
options.merge!(Hash[*options.delete(:options).map {|opt| opt.split('=',2)}.flatten].symbolize_keys!) if options[:options].is_a?(Array) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might I suggest breaking this out into a few lines? Looks very intimidating at first glance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that makes sense... they only question is how :) Maybe?:
if options[:options].is_a?(Array)
server_options = Hash[*options.delete(:options).map {|opt| opt.split('=',2)}.flatten].symbolize_keys!
options.merge!(server_options)
end
or
if options[:options].is_a?(Array)
parsed_server_options = options.delete(:options).map { |opt| opt.split('=', 2) }.flatten
server_options = Hash[*parsed_options].symbolize_keys!
options.merge!(server_options)
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if options[:options].is_a?(Array)
parsed_server_options = options.delete(:options).map { |opt| opt.split('=', 2) }.flatten
server_options = Hash[*parsed_options].symbolize_keys!
options.merge!(server_options)
end
👍
More than acceptable
👍 |
@Ortuna you can push to padrino-start-accepts-handler-options |
Done @Ortuna, thanks! :) |
…ptions Allow padrino start to take handler specific options
Modified
padrino start
to take an extra--options
(-O
) parameter to pass options to the rack handler.For instance, with
puma
you can now do:bundle exec padrino s -O Threads=3:16
and the server will start with 3 to 16 threads.This implementation follows the same syntax that rackup uses for compatibility.
Also implemented --server_options to print out the supported options for the selected handler (application server).
This has been requested a couple of times, the latest in #1451.
I'd still recommend people to run their applications through the application server directly -e.g., puma, unicorn, thin...- instead of using this but it might come in handy for development.
Thoughts @padrino/core-members?