bin/riemann-babbler in riemann-babbler-0.3.1 vs bin/riemann-babbler in riemann-babbler-0.3.3

- old
+ new

@@ -2,11 +2,10 @@ #encoding: utf-8 require 'trollop' require 'yaml' require 'configatron' -require 'parallel' require 'logger' require File.expand_path('../../lib/riemann/version', __FILE__) require File.expand_path('../../lib/deep_merge', __FILE__) require File.expand_path('../../lib/riemann/babbler/plugin', __FILE__) @@ -23,11 +22,11 @@ opt :config, "Config file", :default => "/etc/riemann-babbler/config.yml" end # logger -log = Logger.new(STDOUT) +logger = Logger.new(STDOUT) # merge configs config_file = if File.exist?( opts[:config] ) YAML.load_file( opts[:config] ).to_hash else @@ -38,14 +37,10 @@ config_default = YAML.load_file( File.expand_path('../../config.yml', __FILE__) ) config = config_default.deep_merge( config_file ) configatron.configure_from_hash config -# отправляем к плагинам -$configatron = configatron -$logger = log - # get plugins plugins = [] default_plugins_dir = File.expand_path('../../lib/riemann/babbler/plugins/', __FILE__) Dir.glob( default_plugins_dir + "/*.rb" ) do |file| plugins << file @@ -65,8 +60,18 @@ plugins << file end end # start plugins -Parallel.each( plugins, :in_threads => plugins.count ) do |plugin| - require plugin +plugins.each { |plugin| require plugin } + +plugin_threads = Riemann::Babbler.registered_plugins.map do |plugin| + Thread.new { + plugin.new( configatron, logger ).run + } end + +Signal.trap "USR1" do + plugin_threads.each( &:kill ) +end + +plugin_threads.each( &:join )