From 5214a14990dd0828eb7220ee41ed57be444d8a19 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Fri, 27 Sep 2024 17:50:35 -0700 Subject: [PATCH] Rescue from ActiveRecord::ConnectionTimeoutError MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just to stop filling the crash logs with it… if they spike, we'll be alerted by the downtime monitor anyway. --- app/controllers/application_controller.rb | 8 +++ public/503.html | 59 +++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 public/503.html diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cc7746e5..15a8cc99 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -21,9 +21,12 @@ class ApplicationController < ActionController::Base class AccessDenied < StandardError; end rescue_from AccessDenied, with: :on_access_denied + rescue_from Async::Stop, Async::Container::Terminate, with: :on_request_stopped + rescue_from ActiveRecord::ConnectionTimeoutError, with: :on_db_timeout + def authenticate_user! redirect_to(new_auth_user_session_path) unless user_signed_in? end @@ -65,6 +68,11 @@ class ApplicationController < ActionController::Base status: :internal_server_error end + def on_db_timeout + render file: 'public/503.html', layout: false, + status: :service_unavailable + end + def redirect_back!(default=:back) redirect_to(params[:return_to] || default) end diff --git a/public/503.html b/public/503.html new file mode 100644 index 00000000..ac499199 --- /dev/null +++ b/public/503.html @@ -0,0 +1,59 @@ + + + + + + Dress to Impress: Whelmy mode! + + + +
+ Distressed Grundo programmer +
+

DTI is overloaded!

+

+ There's a lot going on in our server right now… usually this lasts for + a few seconds, then passes? Sorry about this! +

+

+ If this keeps happening, we'll be alerted automatically, and we'll do + our best to get it fixed up 💖 +

+
+
+ +