Method: Synapse::Synapse#run
- Defined in:
- lib/synapse.rb
#run ⇒ Object
start all the watchers and enable haproxy configuration
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/synapse.rb', line 44 def run log.info "synapse: starting..." # start all the watchers @service_watchers.map { |watcher| watcher.start } # main loop loops = 0 loop do @service_watchers.each do |w| raise "synapse: service watcher #{w.name} failed ping!" unless w.ping? end if @config_updated @config_updated = false @config_generators.each do |config_generator| log.info "synapse: configuring #{config_generator.name}" config_generator.update_config(@service_watchers) end end sleep 1 @config_generators.each do |config_generator| config_generator.tick(@service_watchers) end loops += 1 log.debug "synapse: still running at #{Time.now}" if (loops % 60) == 0 end rescue StandardError => e log.error "synapse: encountered unexpected exception #{e.inspect} in main thread" raise e ensure log.warn "synapse: exiting; sending stop signal to all watchers" # stop all the watchers @service_watchers.map(&:stop) end |