lib/eye/patch/process_set.rb in eye-patch-0.1.4 vs lib/eye/patch/process_set.rb in eye-patch-0.1.5

- old
+ new

@@ -14,30 +14,44 @@ def parse_process(process) if process[:count] parse_process_cluster(process) else - parse_single_process(process[:name], process[:config]) + parse_single_process( + process[:name], + process[:config], + process_monitors(process)) end end def parse_process_cluster(process) process[:count].times do |index| name = "#{process[:name]}-#{index}" - parse_single_process(name, indexed_config(process[:config], index)) + parse_single_process( + name, + indexed_config(process[:config], index), + process_monitors(process)) end end - def parse_single_process(name, config) + def parse_single_process(name, config, monitors) self[name] = @group .merge(stdout: config[:stdall], stderr: config[:stdall]) .merge(config) .merge(name: name, group: @group[:name]) + + self[name][:triggers] = self[name][:triggers].merge(monitors[:triggers]) + self[name][:checks] = self[name][:checks].merge(monitors[:checks]) end def indexed_config(config, index) config.each_with_object({}) do |(key, value), result| result[key] = value.is_a?(String) ? value.gsub("{ID}", index.to_s) : value end + end + + def process_monitors(config) + { triggers: OptionSet.new(Eye::Trigger, config[:triggers]), + checks: OptionSet.new(Eye::Checker, config[:checks]) } end end end