Created
August 10, 2008 04:45
-
-
Save ivey/4726 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/merb-core/bootloader.rb b/lib/merb-core/bootloader.rb | |
index 5853c1a..fd15c31 100644 | |
--- a/lib/merb-core/bootloader.rb | |
+++ b/lib/merb-core/bootloader.rb | |
@@ -9,7 +9,6 @@ module Merb | |
self.subclasses, self.after_load_callbacks, self.before_load_callbacks, self.finished = [], [], [], [] | |
class << self | |
- | |
# Adds the inheriting class to the list of subclasses in a position | |
# specified by the before and after methods. | |
# | |
@@ -81,7 +80,8 @@ module Merb | |
# | |
# ==== Returns | |
# Boolean:: Whether or not the bootloader has finished. | |
- def finished?(bootloader) | |
+ def finished?(bootloader=nil) | |
+ bootloader ||= subclasses.last.to_s | |
self.finished.include?(bootloader.to_s) | |
end | |
diff --git a/lib/merb-core/rack/application.rb b/lib/merb-core/rack/application.rb | |
index 3caee63..9a46cf6 100644 | |
--- a/lib/merb-core/rack/application.rb | |
+++ b/lib/merb-core/rack/application.rb | |
@@ -2,15 +2,22 @@ module Merb | |
module Rack | |
class Application | |
- def call(env) | |
- begin | |
- controller = ::Merb::Dispatcher.handle(Merb::Request.new(env)) | |
- rescue Object => e | |
- return [500, {"Content-Type"=>"text/html"}, e.message + "<br/>" + e.backtrace.join("<br/>")] | |
+ def call(env) | |
+ if ::Merb::Bootloader.finished? | |
+ def call(env) | |
+ begin | |
+ controller = ::Merb::Dispatcher.handle(Merb::Request.new(env)) | |
+ rescue Object => e | |
+ return [500, {"Content-Type"=>"text/html"}, e.message + "<br/>" + e.backtrace.join("<br/>")] | |
+ end | |
+ Merb.logger.info "\n\n" | |
+ Merb.logger.flush | |
+ controller.rack_response | |
+ end | |
+ call(env) | |
+ else | |
+ [503, {"Content-Type"=>"text/html"}, "<h1>503 Service Unavailable</h1><p>Please try again in a moment.</p>"] | |
end | |
- Merb.logger.info "\n\n" | |
- Merb.logger.flush | |
- controller.rack_response | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment