additional test configs
[god.git] / test / configs / daemon_events / daemon_events.god
bloba0b62d0436192879eec035caec3bd095c4b9c1ad
1 God.watch do |w|
2   w.name = "daemon-events"
3   w.interval = 5.seconds
4   w.start = '/usr/local/bin/ruby ' + File.join(File.dirname(__FILE__), *%w[simple_server.rb]) + ' start'
5   w.stop = '/usr/local/bin/ruby ' + File.join(File.dirname(__FILE__), *%w[simple_server.rb]) + ' stop'
6   w.uid = 'tom'
7   w.gid = 'tom'
8   w.pid_file = '/var/run/daemon-events.pid'
9   
10   w.behavior(:clean_pid_file)
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, :up) do |on|
21     on.condition(:process_running) do |c|
22       c.running = true
23     end
24   end
26   # start if process is not running
27   w.transition(:up, :start) do |on|
28     on.condition(:process_exits)
29   end
30 end