首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rails + xmpp4r + puma。Whem puma作为守护进程XMPP断开连接

Rails + xmpp4r + puma。Whem puma作为守护进程XMPP断开连接
EN

Stack Overflow用户
提问于 2014-12-05 13:19:10
回答 1查看 86关注 0票数 0

我有一个可以启动xmpp4r客户端的初始化器。当我将puma服务器作为常规进程运行时,它工作得很好。但是,当我将puma作为守护进程(-d选项)启动时,它会工作几秒钟并断开与xmpp服务器的连接。我有单独的线程来处理重新连接,但是当puma是一个守护进程时,它不能工作。

代码语言:javascript
复制
def init_reconnection_timer
    timers = Timers::Group.new
    periodic_timer = timers.every(5) do
      if @client.is_disconnected?
        begin
          Rails.logger.info "XmppConnector ##### reconnecting to #{APP_CONFIG['broker_address']} ..."
          connect
          Rails.logger.info "XmppConnector ##### connected!"
          presence
        rescue
        end
      end
    end
    Thread.new do
      loop do
        timers.wait
      end
    end
  end

当puma是一个守护进程时,我从日志中的这段代码中没有得到任何东西。在rails应用程序启动后,它会像往常一样工作几秒钟,接收消息,iqs,没有错误。然后静默地断开连接。下面是我的类的一个构造函数:

代码语言:javascript
复制
class XmppConnector
  include Singleton

  def initialize
    @jid = Jabber::JID::new(APP_CONFIG['broker_username'] + '@' + APP_CONFIG['broker_address'])
    @jid.resource='rails'
    @client = Jabber::Client::new(@jid)
    connect
    init_presence_callback
    init_message_callback
    init_iq_callback
    init_reconnection_timer
    init_subscription_requests
    presence
    @protocol_interface = RemoteInterface.new
    Rails.logger.info "XmppConnector ##### initialized"
  end

但是当puma在没有-d选项的情况下运行时-没有任何问题。在开发和生产中也是如此,我的工作站和服务器。ruby 2.0.0 puma 2.9.2最小线程数: 0,最大线程数: 16 rails 4.2.0beta4

EN

回答 1

Stack Overflow用户

发布于 2015-03-25 17:20:43

puma中有一个关于初始化器中线程的错误,现在它修复了https://github.com/puma/puma/issues/617

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27309276

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档