whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Keep a copy of the last failure
Date Thu, 01 Jun 2017 14:25:45 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  e6dfbab   Keep a copy of the last failure
e6dfbab is described below

commit e6dfbab5e7ab93b997459ba8da89cd164a613ee5
Author: Sebb <sebb@apache.org>
AuthorDate: Thu Jun 1 15:24:50 2017 +0100

    Keep a copy of the last failure
---
 www/status/monitors/svn.rb | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/www/status/monitors/svn.rb b/www/status/monitors/svn.rb
index 32ba395..d83fd1a 100644
--- a/www/status/monitors/svn.rb
+++ b/www/status/monitors/svn.rb
@@ -23,13 +23,20 @@ Danger - unexpected text in log file
 
 =end
 
+require 'fileutils'
+
 def Monitor.svn(previous_status)
+  logdir = File.expand_path('../../../logs', __FILE__)
+  archive = File.join(logdir,'archive')
+  FileUtils.mkdir(archive) unless File.directory?(archive)
+
   # read cron log
   log = File.expand_path('../../../logs/svn-update', __FILE__)
   data = File.open(log) {|file| file.flock(File::LOCK_EX); file.read}
   updates = data.split(%r{\n(?:/\w+)*/srv/svn/})[1..-1]
 
   status = {}
+  seen_level = {}
 
   # extract status for each repository
   updates.each do |update|
@@ -56,6 +63,7 @@ def Monitor.svn(previous_status)
       if not data
         title = "partial response"
         level = 'warning'
+        seen_level[level] = true
       # data may be a String rather than an array in which case .length is its length, not
1
       elsif String  === data or data.length == 1
         title = "1 file updated"
@@ -67,12 +75,23 @@ def Monitor.svn(previous_status)
     else
       level = 'danger'
       data = lines.dup
+      seen_level[level] = true
     end
 
     status[repository] = {level: level, data: data, href: '../logs/svn-update'}
     status[repository][:title] = title if title
   end
 
+  # save as the highest level seen
+  %w{danger warning}.each do |lvl|
+    if seen_level[lvl]
+      # Save a copy of the log; append the severity so can track more problems
+      file = File.basename(log)
+      FileUtils.copy log, File.join(archive, file + '.' + lvl), preserve: true
+      break
+    end
+  end
+  
   {data: status}
 end
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message