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

Allow padrino start to take handler specific options #1452

Merged
merged 2 commits into from Oct 16, 2013

Conversation

@dariocravero
Copy link
Contributor

@dariocravero dariocravero commented Oct 14, 2013

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?

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)

This comment has been minimized.

@Ortuna

Ortuna Oct 14, 2013
Member

Might I suggest breaking this out into a few lines? Looks very intimidating at first glance.

This comment has been minimized.

@dariocravero

dariocravero Oct 15, 2013
Author Contributor

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

This comment has been minimized.

@Ortuna

Ortuna Oct 15, 2013
Member

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
Copy link
Member

@Ortuna Ortuna commented Oct 14, 2013

👍

@ujifgc
Copy link
Member

@ujifgc ujifgc commented Oct 15, 2013

@Ortuna you can push to padrino-start-accepts-handler-options

@dariocravero
Copy link
Contributor Author

@dariocravero dariocravero commented Oct 15, 2013

Done @Ortuna, thanks! :)

ujifgc added a commit that referenced this pull request Oct 16, 2013
…ptions

Allow padrino start to take handler specific options
@ujifgc ujifgc merged commit 3c80cac into master Oct 16, 2013
1 check failed
1 check failed
default The Travis CI build could not complete due to an error
Details
@ujifgc ujifgc deleted the padrino-start-accepts-handler-options branch Oct 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.