From 439877bdb90478f0f88032d43e4a9972294311de Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Mon, 22 Apr 2013 13:37:16 -0400 Subject: [PATCH] Show a warning if there are email jobs in the retry queue --- app/models/admin_dashboard_data.rb | 15 ++++++++++++++- config/locales/server.en.yml | 1 + lib/jobs.rb | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/models/admin_dashboard_data.rb b/app/models/admin_dashboard_data.rb index ce5cf9a5ff7..ab92c00253c 100644 --- a/app/models/admin_dashboard_data.rb +++ b/app/models/admin_dashboard_data.rb @@ -40,7 +40,15 @@ class AdminDashboardData end def problems - [rails_env_check, host_names_check, gc_checks, sidekiq_check || queue_size_check || clockwork_check, ram_check, facebook_config_check, twitter_config_check, github_config_check].compact + [ rails_env_check, + host_names_check, + gc_checks, + sidekiq_check || queue_size_check || clockwork_check, + ram_check, + facebook_config_check, + twitter_config_check, + github_config_check, + failing_emails_check ].compact end def rails_env_check @@ -84,4 +92,9 @@ class AdminDashboardData def github_config_check I18n.t('dashboard.github_config_warning') if SiteSetting.enable_github_logins and (!SiteSetting.github_client_id.present? or !SiteSetting.github_client_secret.present?) end + + def failing_emails_check + num_failed_jobs = Jobs.num_email_retry_jobs + I18n.t('dashboard.failing_emails_warning', num_failed_jobs: num_failed_jobs) if num_failed_jobs > 0 + end end \ No newline at end of file diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 2e8525b0a39..80f797eedfc 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -346,6 +346,7 @@ en: facebook_config_warning: 'The server is configured to allow signup and log in with Facebook (enable_facebook_logins), but the app id and app secret values are not set. Go to the Site Settings and update the settings. See this guide to learn more.' twitter_config_warning: 'The server is configured to allow signup and log in with Twitter (enable_twitter_logins), but the key and secret values are not set. Go to the Site Settings and update the settings. See this guide to learn more.' github_config_warning: 'The server is configured to allow signup and log in with GitHub (enable_github_logins), but the client id and secret values are not set. Go to the Site Settings and update the settings. See this guide to learn more.' + failing_emails_warning: "There are %{num_failed_jobs} email jobs that failed. Check your config/production.rb file and ensure that the config.action_mailer settings are correct." content_types: education_new_reply: diff --git a/lib/jobs.rb b/lib/jobs.rb index 215c2f1b85d..340d5a55249 100644 --- a/lib/jobs.rb +++ b/lib/jobs.rb @@ -11,6 +11,10 @@ module Jobs end end + def self.num_email_retry_jobs + Sidekiq::RetrySet.new.select { |job| job.klass =~ /Email$/ }.size + end + class Base include Sidekiq::Worker