diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/application.rb | 1 | ||||
-rw-r--r-- | config/initializers/health_checks.rb | 23 | ||||
-rw-r--r-- | config/routes.rb | 2 |
3 files changed, 26 insertions, 0 deletions
diff --git a/config/application.rb b/config/application.rb index fc8e0059e..a514daf3a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -69,6 +69,7 @@ module Alaveteli config.autoload_paths << "#{Rails.root.to_s}/lib/mail_handler" config.autoload_paths << "#{Rails.root.to_s}/lib/attachment_to_html" + config.autoload_paths << "#{Rails.root.to_s}/lib/health_checks" # See Rails::Configuration for more options ENV['RECAPTCHA_PUBLIC_KEY'] = ::AlaveteliConfiguration::recaptcha_public_key diff --git a/config/initializers/health_checks.rb b/config/initializers/health_checks.rb new file mode 100644 index 000000000..7fd1d3dda --- /dev/null +++ b/config/initializers/health_checks.rb @@ -0,0 +1,23 @@ +Rails.application.config.after_initialize do + user_last_created = HealthChecks::Checks::DaysAgoCheck.new( + :failure_message => _('The last user was created over a day ago'), + :success_message => _('The last user was created in the last day')) do + User.last.created_at + end + + incoming_message_last_created = HealthChecks::Checks::DaysAgoCheck.new( + :failure_message => _('The last incoming message was created over a day ago'), + :success_message => _('The last incoming message was created in the last day')) do + IncomingMessage.last.created_at + end + + outgoing_message_last_created = HealthChecks::Checks::DaysAgoCheck.new( + :failure_message => _('The last outgoing message was created over a day ago'), + :success_message => _('The last outgoing message was created in the last day')) do + OutgoingMessage.last.created_at + end + + HealthChecks.add user_last_created + HealthChecks.add incoming_message_last_created + HealthChecks.add outgoing_message_last_created +end diff --git a/config/routes.rb b/config/routes.rb index f557e681b..84ec86792 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -61,6 +61,8 @@ Alaveteli::Application.routes.draw do match '/request/:url_title/download' => 'request#download_entire_request', :as => :download_entire_request #### + resources :health_checks, :only => [:index] + resources :request, :only => [] do resource :report, :only => [:new, :create] end |