Sha256: 316257a737759201de63155d0cf5f96f0c22ef864d3e1708936794faca34b7b0

Contents?: true

Size: 713 Bytes

Versions: 11

Compression:

Stored size: 713 Bytes

Contents

class Eye::Trigger::CheckDependency < Eye::Trigger
  param :names, [Array], true, 5

  def check(transition)
    check_dependency(transition.to_name) if transition.from_name == :up
  end

private

  def check_dependency(to)
    processes = names.map do |name|
      Eye::Control.find_nearest_process(name, process.group_name_pure, process.app_name)
    end.compact
    return if processes.empty?
    processes = Eye::Utils::AliveArray.new(processes)

    act = case to
      when :down, :restarting; :restart
      when :stopping; :stop
      when :unmonitored; :unmonitor
    end

    if act
      processes.each do |p|
        p.schedule act, Eye::Reason.new(:"#{act} dependecies")
      end
    end
  end

end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
eye-0.6.4 lib/eye/trigger/check_dependency.rb
eye-0.6.3 lib/eye/trigger/check_dependency.rb
eye-0.6.2 lib/eye/trigger/check_dependency.rb
eye-0.6.2.pre lib/eye/trigger/check_dependency.rb
ace-eye-0.6.5 lib/eye/trigger/check_dependency.rb
ace-eye-0.6.4 lib/eye/trigger/check_dependency.rb
eye-0.6.1 lib/eye/trigger/check_dependency.rb
ace-eye-0.6.3 lib/eye/trigger/check_dependency.rb
ace-eye-0.6.2 lib/eye/trigger/check_dependency.rb
ace-eye-0.6.1 lib/eye/trigger/check_dependency.rb
eye-0.6 lib/eye/trigger/check_dependency.rb