aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/initialization.textile
diff options
context:
space:
mode:
authorOscar Del Ben <info@oscardelben.com>2012-05-23 08:45:48 -0700
committerOscar Del Ben <info@oscardelben.com>2012-05-23 08:45:48 -0700
commit05a4d8b8597b7cc70ea79b087ee491ffaaf8f504 (patch)
treeb5a16c0e4dfe7149400cb6b4321032d713bf2ad1 /guides/source/initialization.textile
parent2227064b2a26914f662878482fb00dc25546ecd8 (diff)
downloadrails-05a4d8b8597b7cc70ea79b087ee491ffaaf8f504.tar.gz
rails-05a4d8b8597b7cc70ea79b087ee491ffaaf8f504.tar.bz2
rails-05a4d8b8597b7cc70ea79b087ee491ffaaf8f504.zip
[Guides] Rewrite server start section
Diffstat (limited to 'guides/source/initialization.textile')
-rw-r--r--guides/source/initialization.textile22
1 files changed, 20 insertions, 2 deletions
diff --git a/guides/source/initialization.textile b/guides/source/initialization.textile
index dc089bfb90..78790a5e3c 100644
--- a/guides/source/initialization.textile
+++ b/guides/source/initialization.textile
@@ -370,8 +370,9 @@ This method is defined like this:
<ruby>
def start
+ url = "#{options[:SSLEnable] ? 'https' : 'http'}://#{options[:Host]}:#{options[:Port]}"
puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}"
- puts "=> Rails #{Rails.version} application starting in #{Rails.env} on http://#{options[:Host]}:#{options[:Port]}"
+ puts "=> Rails #{Rails.version} application starting in #{Rails.env} on #{url}"
puts "=> Call with -d to detach" unless options[:daemonize]
trap(:INT) { exit }
puts "=> Ctrl-C to shutdown server" unless options[:daemonize]
@@ -381,6 +382,15 @@ def start
FileUtils.mkdir_p(Rails.root.join('tmp', dir_to_make))
end
+ unless options[:daemonize]
+ wrapped_app # touch the app so the logger is set up
+
+ console = ActiveSupport::Logger.new($stdout)
+ console.formatter = Rails.logger.formatter
+
+ Rails.logger.extend(ActiveSupport::Logger.broadcast(console))
+ end
+
super
ensure
# The '-h' option calls exit before @options is set.
@@ -389,7 +399,15 @@ ensure
end
</ruby>
-This is where the first output of the Rails initialization happens. This method creates a trap for +INT+ signals, so if you +CTRL+C+ the server, it will exit the process. As we can see from the code here, it will create the +tmp/cache+, +tmp/pids+, +tmp/sessions+ and +tmp/sockets+ directories if they don't already exist prior to calling +super+. The +super+ method will call +Rack::Server.start+ which begins its definition like this:
+This is where the first output of the Rails initialization happens. This
+method creates a trap for +INT+ signals, so if you +CTRL-C+ the server,
+it will exit the process. As we can see from the code here, it will
+create the +tmp/cache+, +tmp/pids+, +tmp/sessions+ and +tmp/sockets+
+directories. It then calls +wrapped_app+ which is responsible for
+creating the Rack app, before creating and assignig an
+instance of +ActiveSupport::Logger+.
+
+The +super+ method will call +Rack::Server.start+ which begins its definition like this:
<ruby>
def start