From 275bc8e5fb59091952eba3ba8fd01c27b5c8c9eb Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Sat, 16 Jun 2007 17:31:05 -0700 Subject: [PATCH] fixed meddle threading, added gravatar.god example config --- examples/gravatar.god | 23 +++++++++++++++++++++++ lib/god/meddle.rb | 7 ++++--- 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 examples/gravatar.god diff --git a/examples/gravatar.god b/examples/gravatar.god new file mode 100644 index 0000000..3f9511d --- /dev/null +++ b/examples/gravatar.god @@ -0,0 +1,23 @@ +# This is the actual config file used to keep the mongrels of +# gravatar.com running. + +RAILS_ROOT = "/var/www/gravatar2/current" + +God.meddle do |god| + god.interval = 30 # seconds + + %w{8200 8201 8202}.each do |port| + god.watch do |w| + w.name = "gravatar2-mongrel-#{port}" + w.cwd = RAILS_ROOT + w.start = "mongrel_rails cluster::start --only #{port}" + w.stop = "mongrel_rails cluster::stop --only #{port}" + + w.start_if do |start| + start.condition(:process_not_running) do |c| + c.pid_file = File.join(RAILS_ROOT, "log/mongrel.#{port}.pid") + end + end + end + end +end \ No newline at end of file diff --git a/lib/god/meddle.rb b/lib/god/meddle.rb index eb87fe1..b68194a 100644 --- a/lib/god/meddle.rb +++ b/lib/god/meddle.rb @@ -23,8 +23,9 @@ module God def monitor threads = [] + @watches.each do |w| - t = Thread.new do + threads << Thread.new do while true do if a = w.run w.action(a) @@ -32,9 +33,9 @@ module God sleep self.interval end end - t.join - threads << t end + + threads.each { |t| t.join } end end -- 2.11.4.GIT