Re:Puma, a fast concurrent web server for Ruby
by FooBarWidget on Tuesday August 27, 2013 @01:10PM
(#6284720)
I'm one of the authors behind Phusion Passenger (https://www.phusionpassenger.com/), a polyglot web server for Ruby, Python and Node.js.
We recently wrote a demo demonstrating SSE on Phusion Passenger (https://github.com/phusion/passenger-ruby-server-side-events...). During writing of this demo, we found out that sinatra-contrib's streaming code relies on EventMachine. That means that sinatra-contrib's streaming only works on EventMachine-based servers, like Thin and on Goliath.
Based on my knowledge about Puma, I'm pretty sure SSE works fine on Puma as well. The Phusion Passenger SSE demo uses the Rack socket hijacking API (which we've blogged about: http://blog.phusion.nl/2013/01/23/the-new-rack-socket-hijack...) to implement SSE. This approach should work on Puma as well because it supports the Rack socket hijacking API too.
Re:Puma, a fast concurrent web server for Ruby
by sad on Thursday August 29, 2013 @07:59PM
(#6299393)
I created a sample app using Puma and Celluloid to work through similar troubles I was having with Sinatra's streams and Puma. If it helps, it's here: https://github.com/sdeming/cellfun. This does not use EventMachine, depending instead on Celluloid. I work primarily in JRuby and EventMachine has always tripped me up.
content_type "text/event-stream" stream(:keep_open) { |out| settings.connections << out }
From Sinatra, which I assume is then deferring to EventMachine, courtesy of Thin. I'll see if there's a way of forcing EM directly in to the Stream setup...thanks for the pointer.