Commit b407426f authored by an.nguyen's avatar an.nguyen
Browse files

Merge branch '250-mailer-to-admin-when-app-restart' into 'development'

Resolve "mailer to admin when app restart"

Closes #250

See merge request !447
parents 81f15eb5 7575e600
class AppRestartMailJob < ActiveJob::Base
queue_as :default
def perform
AppRestartMailer.send_mail&.deliver_now
end
end
class AppRestartMailer < ActionMailer::Base
default from: ENV['DEVISE_SENDER'] || 'eln'
def text_content
"The application was restarted.\n#{revision}"
end
def revision
if File.exist?('../../revisions.log')
`tail -n 1 ../../revisions.log`
end
end
def send_mail
unless ENV['ADM_EMAILS'].blank?
mail(to: ENV['ADM_EMAILS'], subject: "Rails app restarted") do |format|
format.text { render plain: text_content }
end
end
end
end
......@@ -89,7 +89,11 @@ Rails.application.configure do
:enable_starttls_auto => ENV['SMTP_TLS'] && ENV['SMTP_TLS'].match(/true/),
:openssl_verify_mode => ENV['SMTP_SSL_MODE']
}
config.browserify_rails.commandline_options = "-t [ babelify --presets [ es2015 react ] --plugins [ transform-object-rest-spread ] ] -g uglifyify -p bundle-collapser/plugin "
config.browserify_rails.commandline_options = "-t [ babelify --presets [ es2015 react ] --plugins [ transform-object-rest-spread ] ] -g uglifyify -p bundle-collapser/plugin "
unless defined?(Rails::Console)
config.after_initialize do
AppRestartMailJob.set(wait: 1.minute).perform_later if Delayed::Job.where("handler like ?", "%AppRestartMailJob%").empty?
end
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment