Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

[Guides] Rewrite server start section

  • Loading branch information...
1 parent 05a4d8b commit 13612ae5014a98cdbb86d703b50cbdf66adbcb57 @oscardelben oscardelben committed
Showing with 23 additions and 8 deletions.
  1. +23 −8 guides/source/initialization.textile
31 guides/source/initialization.textile
@@ -410,7 +410,7 @@ instance of +ActiveSupport::Logger+.
The +super+ method will call +Rack::Server.start+ which begins its definition like this:
-def start
+def start &blk
if options[:warn]
$-w = true
@@ -430,22 +430,37 @@ def start
pp wrapped_app
pp app
-In a Rails application, these options are not set at all and therefore aren't used at all. The first line of code that's executed in this method is a call to this method:
+ check_pid! if options[:pid]
+ # Touch the wrapped app, so that the is loaded before
+ # daemonization (i.e. before chdir, etc).
+ wrapped_app
+ daemonize_app if options[:daemonize]
+ write_pid if options[:pid]
+ trap(:INT) do
+ if server.respond_to?(:shutdown)
+ server.shutdown
+ else
+ exit
+ end
+ end
+ wrapped_app, options, &blk
-This method calls another method:
+The interesting part for a Rails app is the last line, Here we encounter the +wrapped_app+ method again, which this time
+we're going to explore more.
@wrapped_app ||= build_app app
-Then the +app+ method here is defined like so:
+The +app+ method here is defined like so:
def app

0 comments on commit 13612ae

Please sign in to comment.
Something went wrong with that request. Please try again.