Skip to content

Commit

Permalink
[feature] replace rack-timeout with slowpoke (#1457)
Browse files Browse the repository at this point in the history
Addresses: 
#1434
#1419 (comment)

Co-authored-by: Pralish Kayastha <[email protected]>
  • Loading branch information
donrestarone and Pralish authored Mar 13, 2023
1 parent 336836e commit bd50172
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ APP_HOST=lvh.me:5250
RECAPTCHA_SITE_KEY=6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy
RECAPTCHA_SECRET_KEY=6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx
SECRET_KEY_BASE='38c72586473e364229897f24f1892f1dc5565776878aa4d8c6bf051258622bd2e923b926ab59b40f912b661216f764d993e8d6b8bbfbc33026e5c954b6c51f9b'
RACK_TIMEOUT_SERVICE_TIMEOUT=80
VIOLET_SERVICE_TIMEOUT=80
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ gem 'stripe-rails'

gem 'devise-two-factor', "4.0.2"

gem "rack-timeout", "~> 0.6"
gem "slowpoke"
6 changes: 5 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ GEM
tilt (~> 2.0)
sitemap_generator (6.1.2)
builder (~> 3.0)
slowpoke (0.4.0)
actionpack
rack-timeout (>= 0.4)
railties (>= 5.2)
spring (2.1.1)
sprockets (4.0.3)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -544,7 +548,6 @@ DEPENDENCIES
puma (~> 5.6)
rack-cors
rack-mini-profiler (~> 3.0)
rack-timeout (~> 0.6)
rails (~> 6.1.5)
rails-controller-testing
ransack
Expand All @@ -558,6 +561,7 @@ DEPENDENCIES
simplecov
sinatra
sitemap_generator
slowpoke
spring
stackprof
stripe-rails
Expand Down
3 changes: 3 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,7 @@

# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true

# Timeout long running requests
config.slowpoke.timeout = ENV['VIOLET_SERVICE_TIMEOUT'].to_i.nonzero? || 15
end
3 changes: 3 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,7 @@
# config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session

# Timeout long running requests
config.slowpoke.timeout = ENV['VIOLET_SERVICE_TIMEOUT'].to_i.nonzero? || 15
end
2 changes: 2 additions & 0 deletions config/environments/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,6 @@
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session

# Timeout long running requests
config.slowpoke.timeout = ENV['VIOLET_SERVICE_TIMEOUT'].to_i.nonzero? || 15
end
3 changes: 3 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true
config.action_view.raise_on_missing_translations = true

# Timeout long running requests
config.slowpoke.timeout = ENV['VIOLET_SERVICE_TIMEOUT'].to_i.nonzero? || 15
end
31 changes: 0 additions & 31 deletions config/initializers/rack_timeout.rb

This file was deleted.

66 changes: 66 additions & 0 deletions public/503.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html>
<head>
<title>This page took too long to load (503)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
.rails-default-error-page {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}

.rails-default-error-page div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}

.rails-default-error-page div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}

.rails-default-error-page h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}

.rails-default-error-page div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>

<body class="rails-default-error-page">
<!-- This file lives in public/503.html -->
<div class="dialog">
<div>
<h1>This page took too long to load.</h1>
</div>
<p>Give it another shot.</p>
</div>
</body>
</html>
File renamed without changes.

0 comments on commit bd50172

Please sign in to comment.