diff --git a/lib/router/router.rb b/lib/router/router.rb index dbd519e..7054be9 100644 --- a/lib/router/router.rb +++ b/lib/router/router.rb @@ -40,6 +40,7 @@ def config(config) @flush_apps_interval = config['flush_apps_interval'] || 30 @active_apps = Set.new @flushing_apps = Set.new + @flushing = false end end @@ -235,6 +236,9 @@ def add_active_app(app_id) def flush_active_apps return unless @enable_nonprod_apps + return if @flushing + @flushing = true + @active_apps, @flushing_apps = @flushing_apps, @active_apps @active_apps.clear @@ -244,6 +248,8 @@ def flush_active_apps log.info("Flushing active apps, app size: #{@flushing_apps.size}, msg size: #{zmsg.size}") EM.next_tick { NATS.publish('router.active_apps', zmsg) } + + @flushing = false end end