Created
September 25, 2013 12:05
-
-
Save carloslopes/6698708 to your computer and use it in GitHub Desktop.
Threaded sinatra app
This file contains hidden or 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
sinatra_thread = Thread.new do | |
require 'sinatra/base' | |
class SinatraServer < Sinatra::Base | |
get '/hi' do | |
"Hello World!" | |
end | |
run! | |
end | |
end | |
other_thread = Thread.new do | |
loop do | |
sleep(2) | |
puts 'foo' | |
end | |
end | |
# Hangs while sinatra is running | |
sinatra_thread.join | |
other_thread.kill |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment