From 8cb594a2e1808cd7d93f3593afed0414016fc56f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 11 Jan 2010 14:01:28 -0800 Subject: Get everyone running on Rails.env and fix the broken environment settings for script/console and script/dbconsole --- railties/lib/rails/commands/server.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 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 09d7207d51..b21ae2a17b 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -38,15 +38,14 @@ module Rails end def start + ENV["RAILS_ENV"] = options[:environment] + puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}" - puts "=> Rails #{Rails.version} application starting on http://#{options[:Host]}:#{options[:Port]}" + puts "=> Rails #{Rails.version} application starting in #{Rails.env} on http://#{options[:Host]}:#{options[:Port]}" puts "=> Call with -d to detach" unless options[:daemonize] trap(:INT) { exit } puts "=> Ctrl-C to shutdown server" unless options[:daemonize] - ENV["RAILS_ENV"] = options[:environment] - RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) - super ensure puts 'Exiting' unless options[:daemonize] -- cgit v1.2.3 From b0994be5bd24559f1362a636b46271de6d6a92d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 15 Jan 2010 10:46:30 +0100 Subject: LogTailer should be invoked after all logs in threads were flushed. --- railties/lib/rails/commands/server.rb | 6 +----- 1 file changed, 1 insertion(+), 5 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 b21ae2a17b..851a21c51d 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -46,6 +46,7 @@ module Rails trap(:INT) { exit } puts "=> Ctrl-C to shutdown server" unless options[:daemonize] + Rails::Subscriber.tail_log = true unless options[:daemonize] super ensure puts 'Exiting' unless options[:daemonize] @@ -53,15 +54,10 @@ module Rails def middleware middlewares = [] - middlewares << [Rails::Rack::LogTailer, log_path] unless options[:daemonize] middlewares << [Rails::Rack::Debugger] if options[:debugger] Hash.new(middlewares) end - def log_path - "log/#{options[:environment]}.log" - end - def default_options super.merge({ :Port => 3000, -- cgit v1.2.3 From 6487d2871cbd44d769c483f47130e18d53e6e381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 15 Jan 2010 12:15:49 +0100 Subject: Fix an issue where log was not being tailed in the first request. --- railties/lib/rails/commands/server.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (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 851a21c51d..115499db05 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -46,7 +46,7 @@ module Rails trap(:INT) { exit } puts "=> Ctrl-C to shutdown server" unless options[:daemonize] - Rails::Subscriber.tail_log = true unless options[:daemonize] + initialize_log_tailer! unless options[:daemonize] super ensure puts 'Exiting' unless options[:daemonize] @@ -58,6 +58,10 @@ module Rails Hash.new(middlewares) end + def log_path + "log/#{options[:environment]}.log" + end + def default_options super.merge({ :Port => 3000, @@ -67,5 +71,14 @@ module Rails :pid => "tmp/pids/server.pid" }) end + + protected + + # LogTailer should not be used as a middleware since the logging happens + # async in a request and the middleware calls are sync. So we send it + # to subscriber which will be responsible for calling tail! in the log tailer. + def initialize_log_tailer! + Rails::Subscriber.log_tailer = Rails::Rack::LogTailer.new(nil, log_path) + end end end -- cgit v1.2.3