From ac6d8942a5ccff0fcc30b6b603c0f4e44a6461b3 Mon Sep 17 00:00:00 2001 From: wmorgan Date: Wed, 6 Jun 2007 00:00:05 +0000 Subject: [PATCH] bugfix: lock file now actually periodically touched; also some minor text and code cleanups git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@438 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- bin/sup | 2 +- lib/sup/index.rb | 29 ++++++++++++++++++++--------- lib/sup/util.rb | 6 ++---- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/bin/sup b/bin/sup index d16ae80..c7d3207 100644 --- a/bin/sup +++ b/bin/sup @@ -65,7 +65,7 @@ rescue Index::LockError => e h.wrap_at = :auto h.say Index.fancy_lock_error_message_for(e) - case h.ask("Should I ask that the process kill itself? ") + case h.ask("Should I ask that process to kill itself? ") when /^\s*y\s*$/i h.say "Ok, suggesting sepuku..." FileUtils.touch Redwood::SUICIDE_FN diff --git a/lib/sup/index.rb b/lib/sup/index.rb index fe7297d..7d1e7a5 100644 --- a/lib/sup/index.rb +++ b/lib/sup/index.rb @@ -29,7 +29,7 @@ class Index @analyzer[:body] = sa @analyzer[:subject] = sa @qparser ||= Ferret::QueryParser.new :default_field => :body, :analyzer => @analyzer - @lock = Lockfile.new lockfile, :retries => 0 + @lock = Lockfile.new lockfile, :retries => 0, :max_age => nil self.class.i_am_the_instance self end @@ -47,21 +47,27 @@ class Index def start_lock_update_thread Redwood::reporting_thread do - sleep 30 - @lock.touch_yourself + while true + sleep 30 + @lock.touch_yourself + end end end def fancy_lock_error_message_for e - mins = (Time.now - e.mtime).to_i / 60 + secs = Time.now - e.mtime + mins = secs.to_i / 60 + time = + if mins == 0 + "#{secs.to_i} seconds" + else + "#{mins} minutes" + end < e $stderr.puts fancy_lock_error_message_for(e) + $stderr.puts <