Skip to content

Instantly share code, notes, and snippets.

@takeru
Created March 1, 2010 06:13
Show Gist options
  • Select an option

  • Save takeru/318127 to your computer and use it in GitHub Desktop.

Select an option

Save takeru/318127 to your computer and use it in GitHub Desktop.
$_rack_request_counter = 0
$_rack_rails_app = nil
rails_dispatcher = lambda{|env|
$_rack_request_counter += 1
if $_rack_request_counter <= 1
if env["REQUEST_METHOD"]=="GET"
res = Rack::Response.new("*", 302)
redir_url = env["REQUEST_URI"] + (env["QUERY_STRING"]=="" ? "?" : "&") + "_spinup_=#{Time.now.to_i}"
res["Location"] = redir_url
res.finish
else
Rack::Response.new("Service Unavailable", 503).finish
end
else
unless $_rack_rails_app
require ::File.expand_path('../config/environment', __FILE__)
$_rack_rails_app = ActionController::Dispatcher.new
end
$_rack_rails_app.call(env)
end
}
#map '/admin' do
# use AppEngine::Rack::AdminRequired
# run rails_dispatcher
#end
map '/' do
run rails_dispatcher
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment