Permalink
Browse files

Merge pull request #1597 from padrino/1260-eval-config

load config.ru with padrino server, fixes #1260
  • Loading branch information...
ujifgc committed Feb 18, 2014
2 parents b0cb8c6 + 1e4ce6e commit a2d22f87edfc70542ead62a9acbb378784f493a7
Showing with 14 additions and 3 deletions.
  1. +2 −2 padrino-core/lib/padrino-core/cli/base.rb
  2. +12 −1 padrino-core/lib/padrino-core/server.rb
@@ -21,15 +21,15 @@ class Base < Thor
method_option :options, :type => :array, :aliases => "-O", :desc => "--options NAME=VALUE NAME2=VALUE2'. pass VALUE to the server as option NAME. If no VALUE, sets it to true. Run '#{$0} --server_options"
method_option :server_options, :type => :boolean, :desc => "Tells the current server handler's options that can be used with --options"
def start
def start(*args)
prepare :start
require File.expand_path("../adapter", __FILE__)
require File.expand_path('config/boot.rb')
if options[:server_options]
puts server_options(options)
else
Padrino::Cli::Adapter.start(options)
Padrino::Cli::Adapter.start(args.last ? options.merge(:config => args.last).freeze : options)
end
end
@@ -9,7 +9,18 @@ module Padrino
#
def self.run!(options={})
Padrino.load!
Server.start(Padrino.application, options)
default_config_file = 'config.ru'
app =
if options[:config] || File.file?(default_config_file)
options[:config] ||= default_config_file
fail "Rack config file `#{options[:config]}` must have `.ru` extension" unless options[:config] =~ /\.ru$/
rack_app, rack_options = Rack::Builder.parse_file(options[:config])
options = rack_options.merge(options)
rack_app
else
Padrino.application
end
Server.start(app, options)
end
##

0 comments on commit a2d22f8

Please sign in to comment.