deprecate God.init in favor of directly setting options
[god.git] / test / configs / child_events / child_events.god
blob67bfb5013f5eda0acea82434c8f417d600ead2dc
1 God.init do |god|
2   god.host = '127.0.0.1'
3 end
5 God.watch do |w|
6   w.name = "child-events"
7   w.interval = 5.seconds
8   w.start = File.join(GOD_ROOT, *%w[test configs child_events simple_server.rb])
9   w.log = File.join(GOD_ROOT, *%w[test configs child_events god.log])
10   
11   # determine the state on startup
12   w.transition(:init, { true => :up, false => :start }) do |on|
13     on.condition(:process_running) do |c|
14       c.running = true
15     end
16   end
17   
18   # determine when process has finished starting
19   w.transition([:start, :restart], :up) do |on|
20     on.condition(:process_running) do |c|
21       c.running = true
22     end
23     
24     # failsafe
25     on.condition(:tries) do |c|
26       c.times = 2
27       c.transition = :start
28     end
29   end
31   # start if process is not running
32   w.transition(:up, :start) do |on|
33     on.condition(:process_exits)
34   end
35   
36   # lifecycle
37   w.lifecycle do |on|
38     on.condition(:flapping) do |c|
39       c.to_state = [:start, :restart]
40       c.times = 5
41       c.within = 20.seconds
42       c.transition = :unmonitored
43       c.retry_in = 10.seconds
44       c.retry_times = 2
45       c.retry_within = 5.minutes
46     end
47   end
48 end