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

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

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.

Copy link
Author

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

Copy link
Member

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

Ortuna commented Oct 14, 2013

👍

@ujifgc
Copy link
Member

ujifgc commented Oct 15, 2013

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

@dariocravero
Copy link
Author

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
@ujifgc ujifgc deleted the padrino-start-accepts-handler-options branch October 16, 2013 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants