Created
December 20, 2018 17:47
-
-
Save marzdgzmn/614969af17f74b3f6fdc2422d7c4cfae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Notification | |
def self.send_email(msg) | |
Pony.mail({ | |
:to => Rise::MirrorManager.configuration.admin_email, | |
:from => "MirrorManager@#{Socket.gethostname}", | |
:via => :smtp, | |
:via_options => { | |
:address => 'aspmx.l.google.com', | |
:port => 25, | |
:domain => Socket.gethostname | |
}, | |
:subject => "[#{Socket.gethostname}]MirrorManager Notification @ #{(Time.now).strftime("[%Y-%m-%d]%A, %H:%M")}", | |
:body => msg | |
}) | |
# notify admin | |
end | |
end | |
at_exit do | |
if $ERROR_INFO | |
puts 'oh yeah' | |
error = { | |
timestamp: Time.now, | |
message: $ERROR_INFO.message, | |
backtrace: $ERROR_INFO.backtrace, | |
gems: Gem.loaded_specs.inject({}) do |m, (n, s)| | |
m.merge(n => s.version) | |
end | |
} | |
Notification.send_email YAML.dump(error) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment