Skip to content

Instantly share code, notes, and snippets.

@marzdgzmn
Created December 20, 2018 17:47
Show Gist options
  • Save marzdgzmn/614969af17f74b3f6fdc2422d7c4cfae to your computer and use it in GitHub Desktop.
Save marzdgzmn/614969af17f74b3f6fdc2422d7c4cfae to your computer and use it in GitHub Desktop.
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