Created
June 10, 2009 16:47
-
-
Save dbalatero/127339 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
# current HEAD | |
require 'sinatra/base' | |
class MyApp < Sinatra::Base | |
get '/' do | |
'test' | |
end | |
end | |
app = Sinatra.new(MyApp) do | |
end | |
thread = Thread.new(app) do |a| | |
a.run! | |
end | |
while !app.running? | |
# block until the app spins up... | |
end | |
# This never gets here. | |
puts "The Sinatra app has booted up finally!" | |
thread.join | |
# wait for ctrl+c for exit. |
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
For the fix: http://github.com/dbalatero/sinatra/commit/7d492b2311502ebe398a1fa860c13920640cf29b | |
The reason that the relevant line in that commit had to move is because Sinatra | |
never makes it past the handler.run() Proc, as calling handler.run() will join | |
on the Thin/Mongrel/etc server until someone sends a Ctrl + C to stop it. | |
By setting running to true inside the Proc, we are guaranteed that to happen before | |
blocking happens on the web server. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment