From 6555c2c02e3fdf8e46fed443fa6944aaad4b315d Mon Sep 17 00:00:00 2001 From: Kevin Clark Date: Wed, 25 Jul 2007 16:34:23 -0700 Subject: [PATCH] Add autostart attribute to prevent processses from starting on god init. Closes PLATFORM-64 --- lib/god/meddle.rb | 2 +- lib/god/watch.rb | 4 ++++ test/configs/test.rb | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/god/meddle.rb b/lib/god/meddle.rb index ca1f9cd..0d94054 100644 --- a/lib/god/meddle.rb +++ b/lib/god/meddle.rb @@ -31,7 +31,7 @@ module God # Schedule all poll conditions and register all condition events def monitor - @watches.each { |w| w.monitor } + @watches.each { |w| w.monitor if w.autostart? } end end diff --git a/lib/god/watch.rb b/lib/god/watch.rb index e2d9d60..30880d5 100644 --- a/lib/god/watch.rb +++ b/lib/god/watch.rb @@ -9,6 +9,9 @@ module God attr_accessor :name, :state, :start, :stop, :restart, :interval, :grace, :user, :group + attr_writer :autostart + def autostart?; @autostart; end + # api attr_accessor :behaviors, :metrics @@ -17,6 +20,7 @@ module God # def initialize(meddle) + @autostart ||= true @meddle = meddle # no grace period by default diff --git a/test/configs/test.rb b/test/configs/test.rb index bf73f7d..33d4a40 100644 --- a/test/configs/test.rb +++ b/test/configs/test.rb @@ -10,6 +10,7 @@ God.meddle do |god| w.interval = 5 # seconds w.start = "mongrel_rails start -P ./log/mongrel.pid -c #{RAILS_ROOT} -p 3001 -d" w.stop = "mongrel_rails stop -P ./log/mongrel.pid -c #{RAILS_ROOT}" + # w.autostart = false # w.user = "kev" # w.group = "kev" -- 2.11.4.GIT