如何从 Rails 应用程序中的守护进程创建队列而不出现“IOError:已关闭流”
在跟踪 twitter-stream 的守护进程中,我有这样的结构:
client.track(*hashtags) do |status|
if status.coordinates != nil
EventMachine.synchrony
job = Qu.enqueue TweetProcessor, status
puts "Enqueued tweet processing #{job.id}"
end
end
end
对于 ques 库,我使用 qu-mongo 我有这个配置,
# /config/initializers/qu.rb
Qu.configure do |c|
c.connection = Mongo::Connection.new('127.0.0.1').db("appname_qu")
end
我已经尝试了很多选项,但它总是导致 IOError:关闭流
。
In daemon, which tracks twitter-stream I have this construction:
client.track(*hashtags) do |status|
if status.coordinates != nil
EventMachine.synchrony
job = Qu.enqueue TweetProcessor, status
puts "Enqueued tweet processing #{job.id}"
end
end
end
For ques library I'm using qu-mongo I have this config
# /config/initializers/qu.rb
Qu.configure do |c|
c.connection = Mongo::Connection.new('127.0.0.1').db("appname_qu")
end
I've tried many options, but it always results with IOError: closed stream
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此问题与此问题相关。有关此内容的更多信息,您可以在此处阅读。因此,就我而言,我只是在守护进程周期开始时将 Rails 的记录器和 qu 的记录器重新分配给同一个文件,并最终关闭它,一切都进展顺利:
This problem is related to this question. More on this you can read here. So, in my case I've just reassign rails' logger and qu's loggers to the same file in the beginning of daemon's cycle and close it in the end, and everything is working out just fine: