rescue event register and implement transition state override
[god.git] / test / configs / child_events / child_events.god
blob7ea5785b7e218a8ef06ecabd6bd05930c1036384
1 God.watch do |w|
2   w.name = "child-events"
3   w.interval = 5.seconds
4   w.start = File.join(File.dirname(__FILE__), *%w[simple_server.rb])
5   
6   # determine the state on startup
7   w.transition(:init, { true => :up, false => :start }) do |on|
8     on.condition(:process_running) do |c|
9       c.running = true
10     end
11   end
12   
13   # determine when process has finished starting
14   w.transition(:start, :up) do |on|
15     on.condition(:process_running) do |c|
16       c.running = true
17     end
18     
19     on.condition(:tries) do |c|
20       c.times = 2
21       c.transition = :start
22     end
23   end
25   # start if process is not running
26   w.transition(:up, :start) do |on|
27     on.condition(:process_exits)
28   end
29 end