나는 xmpp4r 클라이언트를 시작하는 이니셜 라이저를 가지고있다. puma 서버를 일반 프로세스로 실행하면 정상적으로 작동합니다. 하지만 퓨마를 데몬으로 시작할 때 (-d 옵션) 몇 초 동안 작동하고 xmpp 서버와의 연결을 끊습니다. 다시 연결을 처리하는 별도의 스레드가 있지만 푸마가 데몬 일 때 작동하지 않습니다.레일즈 + xmpp4r + 퓨마. 데먼 XMPP 연결을 해제 퓨마 실행
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
푸마가 데몬 일 때 로그에이 코드가 없습니다. 레일 앱을 시작한 직후 몇 초 동안 작동하고 평상시처럼 메시지, iqs, 오류가 발생하지 않습니다. 그런 다음 자동으로 연결을 끊습니다. 여기 내 클래스의 생성자는 다음과 같습니다
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
그러나 때 -d 옵션을 사용하지 않고 퓨마 실행 - 전혀 문제. 개발 및 생산, 워크 스테이션 및 서버에서 동일한 작업을 수행합니다. 루비 2.0.0 퓨마 2.9.2 최소 스레드 : 0, 최대 스레드 : 16 개 레일 4.2.0beta4