thin start --threaded
Using rack adapter
Thin web server (v1.6.2 codename Doc Brown)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop
127.0.0.1 - - [12/Jun/2014 19:22:36] "GET / HTTP/1.1" 200 - 0.1773
127.0.0.1 - - [12/Jun/2014 19:22:36] "GET /layout.css?body=1 HTTP/1.1" 304 - 0.0109
127.0.0.1 - - [12/Jun/2014 19:22:36] "GET /application.css?body=1 HTTP/1.1" 304 - 0.0204
/home/eugeny/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/thread.rb:187:in `handle_interrupt': stream closed (IOError)
from /home/eugeny/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/thread.rb:187:in `pop'
from /home/eugeny/.rvm/gems/ruby-2.0.0-p451@thr_test/gems/eventmachine-1.0.3/lib/eventmachine.rb:950:in `run_deferred_callbacks'
from /home/eugeny/.rvm/gems/ruby-2.0.0-p451@thr_test/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
from /home/eugeny/.rvm/gems/ruby-2.0.0-p451@thr_test/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
from /home/eugeny/.rvm/gems/ruby-2.0.0-p451@thr_test/gems/thin-1.6.2/lib/thin/backends/base.rb:73:in `start'
from /home/eugeny/.rvm/gems/ruby-2.0.0-p451@thr_test/gems/thin-1.6.2/lib/thin/server.rb:162:in `start'
from /home/eugeny/.rvm/gems/ruby-2.0.0-p451@thr_test/gems/thin-1.6.2/lib/thin/controllers/controller.rb:87:in `start'
from /home/eugeny/.rvm/gems/ruby-2.0.0-p451@thr_test/gems/thin-1.6.2/lib/thin/runner.rb:199:in `run_command'
from /home/eugeny/.rvm/gems/ruby-2.0.0-p451@thr_test/gems/thin-1.6.2/lib/thin/runner.rb:155:in `run!'
from /home/eugeny/.rvm/gems/ruby-2.0.0-p451@thr_test/gems/thin-1.6.2/bin/thin:6:in `<top (required)>'
from /home/eugeny/.rvm/gems/ruby-2.0.0-p451@thr_test/bin/thin:23:in `load'
from /home/eugeny/.rvm/gems/ruby-2.0.0-p451@thr_test/bin/thin:23:in `<main>'
from /home/eugeny/.rvm/gems/ruby-2.0.0-p451@thr_test/bin/ruby_executable_hooks:15:in `eval'
from /home/eugeny/.rvm/gems/ruby-2.0.0-p451@thr_test/bin/ruby_executable_hooks:15:in `<main>'
gem 'thin', github: 'macournoyer/thin', branch: 'streaming'
def stream
response.headers['Content-Type'] = 'text/event-stream'
sse = SSE.new(response.stream, retry: 5000, event: 'notify')
3.times do |a|
sse.write({ class_id: __id__ })
sleep 3
end
rescue IOError
logger.info('Client alive channel')
ensure
response.stream.close
end
event = new EventSource('/stream')
event.addEventListener 'notify', (e)->
console.log(e.data)