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