diff --git a/lib/synapse/service_watcher/zookeeper.rb b/lib/synapse/service_watcher/zookeeper.rb index 4e2a1962..8c72a573 100644 --- a/lib/synapse/service_watcher/zookeeper.rb +++ b/lib/synapse/service_watcher/zookeeper.rb @@ -84,13 +84,12 @@ def watch return if @zk.nil? log.debug "synapse: setting watch at #{@discovery['path']}" - @watcher.unsubscribe unless @watcher.nil? - @watcher = @zk.register(@discovery['path'], &watcher_callback) + @watcher = @zk.register(@discovery['path'], &watcher_callback) unless @watcher # Verify that we actually set up the watcher. unless @zk.exists?(@discovery['path'], :watch => true) log.error "synapse: zookeeper watcher path #{@discovery['path']} does not exist!" - raise RuntimeError.new('could not set a ZK watch on a node that should exist') + zk_cleanup end log.debug "synapse: set watch at #{@discovery['path']}" end