Skip to content

Instantly share code, notes, and snippets.

@carloslopes
Created September 25, 2013 12:05
Show Gist options
  • Save carloslopes/6698708 to your computer and use it in GitHub Desktop.
Save carloslopes/6698708 to your computer and use it in GitHub Desktop.
Threaded sinatra app
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