Fix server environment [#3877 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
f337ebc308
commit
cafe882d12
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user