Commit f8e8e10e79b7600f13b4e0b57ba5f95faed9bb4a:
avoid/recover from partial updates
Branch: refs/heads/master
Author: Sam Ruby <[email protected]>
Committer: Sam Ruby <[email protected]>
Pusher: rubys <[email protected]>
------------------------------------------------------------
www/status/monitors/svn.rb | ++++++++ -----
------------------------------------------------------------
13 changes: 8 additions, 5 deletions.
------------------------------------------------------------
diff --git a/www/status/monitors/svn.rb b/www/status/monitors/svn.rb
index c39a805..ab07aeb 100644
--- a/www/status/monitors/svn.rb
+++ b/www/status/monitors/svn.rb
@@ -4,9 +4,9 @@
def Monitor.svn(previous_status)
# read cron log
- log = File.expand_path('../../www/logs/svn-update')
- updates = File.read(log).split("\n/srv/svn/")
- updates.shift
+ log = File.expand_path('../../../logs/svn-update', __FILE__)
+ data = File.open(log) {|file| file.flock(File::LOCK_EX); file.read}
+ updates = data.split("\n/srv/svn/")[1..-1]
status = {}
@@ -30,7 +30,10 @@ def Monitor.svn(previous_status)
lines.reject! {|line| line =~ /^[ADU] /}
if lines.empty?
- if data.length == 1
+ if not data
+ title = "partial response"
+ level = 'warning'
+ elsif data.length == 1
title = "1 file updated"
else
title = "#{data.length} files updated"
@@ -42,7 +45,7 @@ def Monitor.svn(previous_status)
data = lines.dup
end
- status[repository] = {level: level, data: data}
+ status[repository] = {level: level, data: data, href: '../logs/svn-update'}
status[repository][:title] = title if title
end