From a193401bf8809e6339d92d4a664b287d6f44a14c Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 28 Sep 2007 22:53:37 -0700 Subject: [PATCH] make cli commands run only if necessary --- bin/god | 3 --- lib/god.rb | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/bin/god b/bin/god index 71e492c..ed7b271 100755 --- a/bin/god +++ b/bin/god @@ -296,13 +296,10 @@ begin exit end - # else - # puts opts.help end rescue Exception => e unless e.instance_of?(SystemExit) puts e.message puts e.backtrace.join("\n") end - abort end \ No newline at end of file diff --git a/lib/god.rb b/lib/god.rb index 4b736fd..8d083b0 100644 --- a/lib/god.rb +++ b/lib/god.rb @@ -285,13 +285,13 @@ module God # do the command case command when "start", "monitor" - watches.each { |w| jobs << Thread.new { w.monitor } } + watches.each { |w| jobs << Thread.new { w.monitor if w.state != :up } } when "restart" watches.each { |w| jobs << Thread.new { w.move(:restart) } } when "stop" - watches.each { |w| jobs << Thread.new { w.unmonitor.action(:stop) } } + watches.each { |w| jobs << Thread.new { w.unmonitor.action(:stop) if w.state != :unmonitored } } when "unmonitor" - watches.each { |w| jobs << Thread.new { w.unmonitor } } + watches.each { |w| jobs << Thread.new { w.unmonitor if w.state != :unmonitored } } else raise InvalidCommandError.new end -- 2.11.4.GIT