How To Run EventMachine and Serve Pages In Sinatra?

Viewed 1807

I'm building a Sinatra app that uses TweetStream (which listens for Tweets using EventMachine). I would also like the app to serve pages like a normal Sinatra app but it seems like Sinatra can't "listen" for page requests when it's "listening" for Tweets.

Is this something I can fix by using a different server or structuring my app in a different way? I've tried using WebBrick and Thin.

Here is basically what I'm doing:

class App < Sinatra::Base

  # listening for tweets
  @client = TweetStream::Client.new
  @client.track(terms) do |status|
    # do some stuff when I detect terms
  end  

  get '/' do
    "Here's some page content!"
  end

end
2 Answers
Related