Sha256: 5d98a454de63b6adbb5364fc950c05cb4b7be6da2d2a04f580a28468cee8a690

Contents?: true

Size: 796 Bytes

Versions: 4

Compression:

Stored size: 796 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

    processes = processes.compact.select { |p| p.state_name != :unmonitored }
    return if processes.empty?
    processes = Eye::Utils::AliveArray.new(processes)

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

    if act
      processes.each do |p|
        p.schedule command: act, reason: "#{act} dependecies"
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eye-0.9.2.nosigar lib/eye/trigger/check_dependency.rb
eye-0.9.2 lib/eye/trigger/check_dependency.rb
eye-0.9.1 lib/eye/trigger/check_dependency.rb
eye-0.9.pre lib/eye/trigger/check_dependency.rb