Rescue from ActiveRecord::ConnectionTimeoutError
Just to stop filling the crash logs with it… if they spike, we'll be alerted by the downtime monitor anyway.
This commit is contained in:
parent
06a89689d8
commit
5214a14990
2 changed files with 67 additions and 0 deletions
|
@ -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
|
||||
|
|
59
public/503.html
Normal file
59
public/503.html
Normal file
|
@ -0,0 +1,59 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Dress to Impress: Whelmy mode!</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
background-color: #fff;
|
||||
color: #666;
|
||||
font-family: arial, sans-serif;
|
||||
padding: 2em 1em;
|
||||
}
|
||||
|
||||
main {
|
||||
border: 1px solid #ccc;
|
||||
margin-inline: auto;
|
||||
padding: 1em;
|
||||
max-width: 600px;
|
||||
|
||||
display: grid;
|
||||
grid-template-areas: "illustration body";
|
||||
grid-template-columns: auto 1fr;
|
||||
column-gap: 1em;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.5em;
|
||||
margin: 0;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<img
|
||||
width="100"
|
||||
height="100"
|
||||
alt="Distressed Grundo programmer"
|
||||
src="/images/error-grundo.png"
|
||||
/>
|
||||
<div>
|
||||
<h1>DTI is overloaded!</h1>
|
||||
<p>
|
||||
There's a lot going on in our server right now… usually this lasts for
|
||||
a few seconds, then passes? Sorry about this!
|
||||
</p>
|
||||
<p>
|
||||
If this keeps happening, we'll be alerted automatically, and we'll do
|
||||
our best to get it fixed up 💖
|
||||
</p>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue