* VRFS-430; found another edge case on initialization of websocket-gateway requiring rework of startup code
This commit is contained in:
parent
e8fbd2e263
commit
52287d054f
|
|
@ -38,7 +38,7 @@ module JamWebsockets
|
|||
|
||||
end
|
||||
|
||||
def start(connect_time_stale, options={:host => "localhost", :port => 5672})
|
||||
def start(connect_time_stale, options={:host => "localhost", :port => 5672}, &block)
|
||||
|
||||
@log.info "startup"
|
||||
|
||||
|
|
@ -48,6 +48,7 @@ module JamWebsockets
|
|||
@amqp_connection_manager = AmqpConnectionManager.new(true, 4, :host => options[:host], :port => options[:port])
|
||||
@amqp_connection_manager.connect do |channel|
|
||||
register_topics(channel)
|
||||
block.call
|
||||
end
|
||||
|
||||
rescue => e
|
||||
|
|
|
|||
|
|
@ -20,21 +20,22 @@ module JamWebsockets
|
|||
@log.info "starting server #{host}:#{port} with staleness_time=#{connect_time_stale}; reconnect time = #{connect_time_expire}"
|
||||
|
||||
EventMachine.run do
|
||||
@router.start(connect_time_stale)
|
||||
@router.start(connect_time_stale) do
|
||||
# take stale off the expire limit because the call to stale will
|
||||
# touch the updated_at column, adding an extra stale limit to the expire time limit
|
||||
expire_time = connect_time_expire > connect_time_stale ? connect_time_expire - connect_time_stale : connect_time_expire
|
||||
start_connection_expiration(expire_time)
|
||||
start_connection_flagger(connect_time_stale)
|
||||
|
||||
start_websocket_listener(host, port, options[:emwebsocket_debug])
|
||||
end
|
||||
|
||||
# if you don't do this, the app won't exit unless you kill -9
|
||||
at_exit do
|
||||
@log.info "cleaning up server"
|
||||
@router.cleanup
|
||||
end
|
||||
|
||||
# take stale off the expire limit because the call to stale will
|
||||
# touch the updated_at column, adding an extra stale limit to the expire time limit
|
||||
expire_time = connect_time_expire > connect_time_stale ? connect_time_expire - connect_time_stale : connect_time_expire
|
||||
start_connection_expiration(expire_time)
|
||||
start_connection_flagger(connect_time_stale)
|
||||
|
||||
start_websocket_listener(host, port, options[:emwebsocket_debug])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue