提交 cafe882d 编写于 作者: S Simo Niemelä 提交者: José Valim

Fix server environment [#3877 status:resolved]

Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 f337ebc3
......@@ -33,10 +33,13 @@
require APP_PATH
Rails::Console.start(Rails::Application)
when 's', 'server'
require APP_PATH
require 'rails/commands/server'
# Initialize the server first, so environment options are set
server = Rails::Server.new
require APP_PATH
Dir.chdir(Rails::Application.root)
Rails::Server.start
server.start
when 'db', 'dbconsole'
require 'rails/commands/dbconsole'
require APP_PATH
......
......@@ -6,8 +6,8 @@ module Rails
class Server < ::Rack::Server
class Options
def parse!(args)
options = {}
args = args.dup
args, options = args.dup, {}
opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: rails server [options]"
opts.on("-p", "--port=port", Integer,
......@@ -34,13 +34,20 @@ def parse!(args)
end
end
def initialize(*)
super
set_environment
end
def opt_parser
Options.new
end
def start
ENV["RAILS_ENV"] = options[:environment]
def set_environment
ENV["RAILS_ENV"] ||= options[:environment]
end
def start
puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}"
puts "=> Rails #{Rails.version} application starting in #{Rails.env} on http://#{options[:Host]}:#{options[:Port]}"
puts "=> Call with -d to detach" unless options[:daemonize]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册