Sha256: fef944f80f834a34f29a188e1bb40f717e849dae8b6f1ae1f1d8d6a629dfdb2f
Contents?: true
Size: 931 Bytes
Versions: 3
Compression:
Stored size: 931 Bytes
Contents
require 'thread' require 'open3' require 'populus/pool' require 'json' module Populus class WatchThread def self.consul_watch(*args) wait = Thread.fork do begin stdin, stdout, stderr = *Open3.popen3( Populus.consul_bin, 'watch', *args, '/bin/cat' ) stdin.close name = args[args.index('-name') + 1] while l = stdout.gets Populus.logger.debug "accept JSON: %s" % l data = JSON.parse l accepters = Populus::Pool.find_events_by_name(name) accepters.each do |accepter| begin accepter.accept(data) rescue => e Populus.logger.warn "Error on event: %s, %s. Skip." % [e.class, e.message] end end end rescue => e Populus.logger.error e end end return wait end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
populus-0.0.4 | lib/populus/watch_thread.rb |
populus-0.0.3 | lib/populus/watch_thread.rb |
populus-0.0.1 | lib/populus/watch_thread.rb |