From 530b8ff5ae811e0dd5e1343b478f42eed6fffdbd Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Tue, 24 Nov 2009 13:03:24 -0800 Subject: Have script/* and Rakefile use the application object --- railties/lib/rails/commands/server.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'railties/lib/rails/commands/server.rb') diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index ff2282a534..57b7c6a49c 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -37,6 +37,15 @@ module Rails Options.new end + def self.start(app) + new(app).start + end + + def initialize(app) + super() # Call Rack::Server#initialize without passing any options to use. + @app = app + end + def start puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}" puts "=> Rails #{Rails.version} application starting on http://#{options[:Host]}:#{options[:Port]}" @@ -54,20 +63,24 @@ module Rails def middleware middlewares = [] - middlewares << [Rails::Rack::LogTailer] unless options[:daemonize] + middlewares << [Rails::Rack::LogTailer, log_path] unless options[:daemonize] middlewares << [Rails::Rack::Debugger] if options[:debugger] Hash.new(middlewares) end + def log_path + "#{File.expand_path(@app.root)}/log/#{options[:environment]}.log" + end + def default_options { :Port => 3000, :Host => "0.0.0.0", :environment => (ENV['RAILS_ENV'] || "development").dup, - :rack_file => "#{Rails.root}/config.ru", + :rack_file => "#{@app.root}/config.ru", :daemonize => false, :debugger => false, - :pid => "#{Rails.root}/tmp/pids/server.pid", + :pid => "#{@app.root}/tmp/pids/server.pid", :AccessLog => [] } end -- cgit v1.2.3