Sha256: 86c91371067bd1d76e1eb7581db4429fc403f460c1739334d507d3e453c04167

Contents?: true

Size: 753 Bytes

Versions: 1

Compression:

Stored size: 753 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]

    process.notify(:info, 'yahho, process up') if states[-compare.length..-1] == compare
  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

1 entries across 1 versions & 1 rubygems

Version Path
eye-0.10.1.pre examples/custom_trigger.eye