This commit is contained in:
Albert Yi
2018-07-02 10:49:26 -07:00
parent f4d5932a66
commit c01a1f0f00
3 changed files with 11 additions and 7 deletions

View File

@@ -7,9 +7,11 @@ class DelayedJobErrorChecker
errors = Delayed::Job.where("last_error is not null").limit(100).pluck(:last_error).map {|x| x[0..100]}
if errors.size == 100
mail = Mail.new do
from "webmaster@danbooru.donmai.us"
to "r888888888@gmail.com"
subject "[danbooru] Delayed job error count at #{errors}"
from Danbooru.config.contact_email
to Danbooru.config.contact_email
CurrentUser.as_system do
subject "[#{Danbooru.config.app_name}] Delayed job error count at #{errors}"
end
body errors.uniq.join("\n")
end
mail.delivery_method :sendmail

View File

@@ -7,9 +7,11 @@ class UploadErrorChecker
uploads = Upload.where("status like 'error%' and status not like 'error: Upload::Error - Post with MD5%' and status not like 'error: RuntimeError - duplicate%' and created_at >= ?", 1.hour.ago)
if uploads.size > 5
mail = Mail.new do
from "webmaster@danbooru.donmai.us"
to "r888888888@gmail.com"
subject "[danbooru] Upload error count at #{uploads.size}"
from Danbooru.config.contact_email
to Danbooru.config.contact_email
CurrentUser.as_system do
subject "[#{Danbooru.config.app_name}] Upload error count at #{uploads.size}"
end
body uploads.map {|x| x.status}.join("\n")
end
mail.delivery_method :sendmail

View File

@@ -1,5 +1,5 @@
set :output, "/var/log/whenever.log"
env "MAILTO", "webmaster@danbooru.donmai.us"
#env "MAILTO", "webmaster@danbooru.donmai.us"
every 1.hour do
runner "UploadErrorChecker.new.check!"