Permalink
Browse files

demonstrate custom behaviors

  • Loading branch information...
1 parent c84031d commit 74b38b5cb46d4137a90fca7471610e2736f96475 @jnewland committed Jul 8, 2008
Showing with 40 additions and 0 deletions.
  1. +40 −0 custom_behvaior.god
View
@@ -0,0 +1,40 @@
+module God
+ module Behaviors
+ class Speak < Behavior
+
+ def before_start
+ `say "Starting now"`
+
+ 'announced start'
+ end
+
+ def before_stop
+ `say "Stopping now"`
+
+ 'announced stop'
+ end
+
+ end
+ end
+end
+
+God.watch do |w|
+ w.name = "leaky"
+ w.interval = 5.second
+ w.start = 'ruby ' + File.dirname(__FILE__) + '/scripts/leaky.rb'
+
+ w.behavior(:speak)
+
+ w.start_if do |start|
+ start.condition(:process_running) do |c|
+ c.running = false
+ end
+ end
+
+ w.restart_if do |restart|
+ restart.condition(:memory_usage) do |c|
+ c.above = 2.megabytes
+ end
+ end
+
+end

0 comments on commit 74b38b5

Please sign in to comment.