From e8856a42a9c14ba8567997999fdd2fc500efb7e7 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Tue, 10 Jul 2007 09:07:59 -0700 Subject: [PATCH] first stab at event integration and some new ideas about lifecycle --- examples/local.god | 2 +- lib/god.rb | 2 ++ lib/god/watch.rb | 1 + test/configs/real.rb | 8 ++++---- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/local.god b/examples/local.god index 3701a6e..f6d29ae 100644 --- a/examples/local.god +++ b/examples/local.god @@ -23,7 +23,7 @@ God.meddle do |god| # start if process is not running w.start_if do |start| - start.condition(:process_not_running) do |c| + start.condition(:process_exits) do |c| c.pid_file = pid_file end end diff --git a/lib/god.rb b/lib/god.rb index 1433fea..d264eaa 100644 --- a/lib/god.rb +++ b/lib/god.rb @@ -1,4 +1,5 @@ $:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed +$:.unshift File.join(File.dirname(__FILE__), *%w[.. ext kqueue_handler]) # internal requires require 'god/base' @@ -12,6 +13,7 @@ require 'god/behaviors/clean_pid_file' require 'god/condition' require 'god/conditions/timeline' require 'god/conditions/process_not_running' +require 'god/conditions/process_exits' require 'god/conditions/memory_usage' require 'god/conditions/cpu_usage' require 'god/conditions/always' diff --git a/lib/god/watch.rb b/lib/god/watch.rb index af8f38b..eec4cdf 100644 --- a/lib/god/watch.rb +++ b/lib/god/watch.rb @@ -104,6 +104,7 @@ module God [:start, :restart].each do |cmd| self.conditions[cmd].each do |c| @meddle.timer.register(self, c, cmd) if c.kind_of?(PollCondition) + c.register(self) if c.kind_of?(EventCondition) end end end diff --git a/test/configs/real.rb b/test/configs/real.rb index 8b1c6d9..2d9b720 100644 --- a/test/configs/real.rb +++ b/test/configs/real.rb @@ -21,13 +21,13 @@ God.meddle do |god| # start if process is not running w.start_if do |start| - # start.condition(:process_exits) do |c| - # c.pid_file = pid_file - # end - start.condition(:process_not_running) do |c| c.pid_file = pid_file end + + start.condition(:process_exits) do |c| + c.pid_file = pid_file + end end # restart if memory or cpu is too high -- 2.11.4.GIT