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: Add email stage (temp destination for initial testing)
Date Fri, 08 Apr 2016 13:51:48 GMT
This is an automated email from the ASF dual-hosted git repository.

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

The following commit(s) were added to refs/heads/master by this push:
       new  b32322b   Add email stage (temp destination for initial testing)
b32322b is described below

commit b32322b72467de43100ba5d8c2c14ebf92614f79
Author: Sebb <sebb@apache.org>
AuthorDate: Fri Apr 8 14:51:38 2016 +0100

    Add email stage (temp destination for initial testing)
---
 www/status/monitors/public_json.rb | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/www/status/monitors/public_json.rb b/www/status/monitors/public_json.rb
index 466f31c..1359207 100644
--- a/www/status/monitors/public_json.rb
+++ b/www/status/monitors/public_json.rb
@@ -40,6 +40,7 @@ def Monitor.public_json(previous_status)
         level: 'success' # to agree with normalise
       }
       contents = File.read(log, encoding: Encoding::UTF_8)
+      contents_save = contents.dup # in case we need to send an email
 
       # Ignore Wunderbar logging for normal messages (may occur multiple times)
       contents.gsub! /^(_INFO|_DEBUG) .*?\n+/, ''
@@ -91,6 +92,27 @@ def Monitor.public_json(previous_status)
           file = File.basename(log)
           FileUtils.copy log, File.join(archive, file + '.' + lvl), preserve: true
           $stderr.puts "Would send e-mail for #{name} #{lvl}"
+          begin
+            require 'mail'
+            $LOAD_PATH.unshift File.realpath(File.expand_path('../../../../lib', __FILE__))
+            require 'whimsy/asf'
+            ASF::Mail.configure
+            mail = Mail.new do
+            from 'Public JSON job monitor  <dev@whimsical.apache.org>'
+      #            to 'Notification List <notifications@whimsical.apache.org>'
+              to 'sebbaz@gmail.com' # TEMP for testing purposes
+              subject "Problem (#{lvl}) detected in #{name} job"
+              body "\nLOG: #{contents_save}\nSTATUS: #{status[name]}\n"
+            end
+            # in spite of what the docs say, this does not seem to work in the body above
+            mail.charset = 'utf-8'
+            # Replace .mail suffix with more accurate one
+            mail.message_id = "<#{Mail.random_tag}@#{::Socket.gethostname}.apache.org>"
+            # deliver mail
+            mail.deliver!
+          rescue => e
+            $stderr.puts "Send mail failed: exception #{e}" # record error in server log
+          end
         end
       end
 

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

Mime
View raw message