change task mutex to monitor and synchronize move method
[god.git] / test / configs / degrading_lambda / degrading_lambda.god
blob87dd2a37163e2e8a9c2f0a3187c68103c997d0dc
1 God.watch do |w|
2   w.name = 'degrading-lambda'
3   w.start = 'ruby ' + File.join(File.dirname(__FILE__), *%w[tcp_server.rb])
4   w.interval = 5
5   w.grace = 2
6   w.group = 'test'
7   
8   w.start_if do |start|
9     start.condition(:process_running) do |c|
10       c.running = false
11     end
12   end
13   
14   w.restart_if do |restart|
15     restart.condition(:degrading_lambda) do |c|
16       require 'socket'
17       c.lambda = lambda {
18         begin
19           sock = TCPSocket.open('127.0.0.1', 9090)
20           sock.send "2\n", 0
21           retval = sock.gets
22           puts "Retval is #{retval}"
23           sock.close
24           retval
25         rescue
26           false
27         end
28       }
29     end
30   end
31 end