Sha256: 33e1b0dd2b8424b0d6373628268175a3690b5338d36b7e658081891f4810b607

Contents?: true

Size: 767 Bytes

Versions: 9

Compression:

Stored size: 767 Bytes

Contents

# send notify when many times crashed process, finally resolved

class Eye::Trigger::FixCrash < Eye::Trigger::Custom

  param :times, Integer, nil, 1
  param_default :to, :up

  def check(_)
    # process states here like this: [..., :starting, :down, :starting, :down, :starting, :up]
    states = process.states_history.states

    # states to compare with
    compare = [:starting, :down] * times + [:starting, :up]

    if states[-compare.length..-1] == compare
      process.notify(:info, 'yahho, process up')
    end
  end

end

Eye.app :custom_trigger do
  trigger :fix_crash

  process :some do
    pid_file '/tmp/custom_trigger_some.pid'
    start_command "ruby -e 's = `cat /tmp/bla`; exit(1) unless s =~ /bla/; loop { sleep 1 } '"
    daemonize!
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
eye-0.10.0 examples/custom_trigger.eye
eye-0.10.0.alpha2 examples/custom_trigger.eye
eye-0.10.0.alpha examples/custom_trigger.eye
eye-0.9.4.nosigar examples/custom_trigger.eye
eye-0.9.4 examples/custom_trigger.eye
eye-0.9.3 examples/custom_trigger.eye
eye-0.9.2.nosigar examples/custom_trigger.eye
eye-0.9.2 examples/custom_trigger.eye
eye-0.9.1 examples/custom_trigger.eye