这是我config.ru
的代码:
require 'rubygems'
require 'bundler'
Bundler.require
require 'faye'
$stdout.sync = true
EM.synchrony do
EM.error_handler do |e|
puts e.message
puts e.backtrace
end
Faye::WebSocket.load_adapter('thin')
o_faye_server = Faye::RackAdapter.new(:mount => '/faye', :timeout => 15)
puts "Running thin with update"
thin = Rack::Handler.get("thin")
thin.run(o_faye_server,:Port => ENV["PORT"].to_i)
puts "Thin started on #{ENV["PORT"]}"
EM.add_periodic_timer(120) do
Fiber.new do
puts "Output"
end.resume
end
end
在应用程序日志中,我看到了:
2013-03-15T10:10:52+00:00 app[web.1]: Running thin with update
2013-03-15T10:10:52+00:00 app[web.1]: >> Thin web server (v1.5.0 codename Knife)
2013-03-15T10:10:52+00:00 app[web.1]: >> Maximum connections set to 1024
2013-03-15T10:10:52+00:00 app[web.1]: >> Listening on 0.0.0.0:21453, CTRL+C to stop
2013-03-15T10:10:52+00:00 app[web.1]: Thin started on 21453
2013-03-15T10:10:52+00:00 app[web.1]: Output
2013-03-15T10:10:54+00:00 heroku[web.1]: Process exited with status 0
EventMachine已停止,但Faye应用程序继续提供Web请求。为什么会这样?其他时候,当我推送代码时,我看到类似的东西:
2013-03-15T10:24:47+00:00 app[web.1]: Running thin with update
2013-03-15T10:24:47+00:00 app[web.1]: >> Thin web server (v1.5.0 codename Knife)
2013-03-15T10:24:47+00:00 app[web.1]: >> Maximum connections set to 1024
2013-03-15T10:24:47+00:00 app[web.1]: >> Listening on 0.0.0.0:32679, CTRL+C to stop
2013-03-15T10:24:47+00:00 app[web.1]: Thin started on 32679
2013-03-15T10:24:47+00:00 app[web.1]: Output
2013-03-15T10:24:47+00:00 app[web.1]: Output
2013-03-15T10:24:47+00:00 app[web.1]: Output
2013-03-15T10:24:47+00:00 app[web.1]: Output
2013-03-15T10:24:47+00:00 app[web.1]: Output
2013-03-15T10:24:47+00:00 app[web.1]: Output
它要么以奇怪的方式对它们进行排队,要么在发布之间没有正确地停止进程。有没有人遇到过这个?