Skip to content

Commit bd50172

Browse files
[feature] replace rack-timeout with slowpoke (#1457)
Addresses: #1434 #1419 (comment) Co-authored-by: Pralish Kayastha <50227291+Pralish@users.noreply.github.com>
1 parent 336836e commit bd50172

File tree

10 files changed

+84
-34
lines changed

10 files changed

+84
-34
lines changed

.env.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ APP_HOST=lvh.me:5250
99
RECAPTCHA_SITE_KEY=6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy
1010
RECAPTCHA_SECRET_KEY=6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx
1111
SECRET_KEY_BASE='38c72586473e364229897f24f1892f1dc5565776878aa4d8c6bf051258622bd2e923b926ab59b40f912b661216f764d993e8d6b8bbfbc33026e5c954b6c51f9b'
12-
RACK_TIMEOUT_SERVICE_TIMEOUT=80
12+
VIOLET_SERVICE_TIMEOUT=80

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,4 @@ gem 'stripe-rails'
122122

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

125-
gem "rack-timeout", "~> 0.6"
125+
gem "slowpoke"

Gemfile.lock

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ GEM
430430
tilt (~> 2.0)
431431
sitemap_generator (6.1.2)
432432
builder (~> 3.0)
433+
slowpoke (0.4.0)
434+
actionpack
435+
rack-timeout (>= 0.4)
436+
railties (>= 5.2)
433437
spring (2.1.1)
434438
sprockets (4.0.3)
435439
concurrent-ruby (~> 1.0)
@@ -544,7 +548,6 @@ DEPENDENCIES
544548
puma (~> 5.6)
545549
rack-cors
546550
rack-mini-profiler (~> 3.0)
547-
rack-timeout (~> 0.6)
548551
rails (~> 6.1.5)
549552
rails-controller-testing
550553
ransack
@@ -558,6 +561,7 @@ DEPENDENCIES
558561
simplecov
559562
sinatra
560563
sitemap_generator
564+
slowpoke
561565
spring
562566
stackprof
563567
stripe-rails

config/environments/development.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,7 @@
8484

8585
# Uncomment if you wish to allow Action Cable access from any origin.
8686
# config.action_cable.disable_request_forgery_protection = true
87+
88+
# Timeout long running requests
89+
config.slowpoke.timeout = ENV['VIOLET_SERVICE_TIMEOUT'].to_i.nonzero? || 15
8790
end

config/environments/production.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,7 @@
129129
# config.active_record.database_selector = { delay: 2.seconds }
130130
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
131131
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
132+
133+
# Timeout long running requests
134+
config.slowpoke.timeout = ENV['VIOLET_SERVICE_TIMEOUT'].to_i.nonzero? || 15
132135
end

config/environments/staging.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,6 @@
133133
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
134134
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
135135

136+
# Timeout long running requests
137+
config.slowpoke.timeout = ENV['VIOLET_SERVICE_TIMEOUT'].to_i.nonzero? || 15
136138
end

config/environments/test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,7 @@
6161
# Annotate rendered view with file names.
6262
# config.action_view.annotate_rendered_view_with_filenames = true
6363
config.action_view.raise_on_missing_translations = true
64+
65+
# Timeout long running requests
66+
config.slowpoke.timeout = ENV['VIOLET_SERVICE_TIMEOUT'].to_i.nonzero? || 15
6467
end

config/initializers/rack_timeout.rb

Lines changed: 0 additions & 31 deletions
This file was deleted.

public/503.html

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>This page took too long to load (503)</title>
5+
<meta name="viewport" content="width=device-width,initial-scale=1">
6+
<style>
7+
.rails-default-error-page {
8+
background-color: #EFEFEF;
9+
color: #2E2F30;
10+
text-align: center;
11+
font-family: arial, sans-serif;
12+
margin: 0;
13+
}
14+
15+
.rails-default-error-page div.dialog {
16+
width: 95%;
17+
max-width: 33em;
18+
margin: 4em auto 0;
19+
}
20+
21+
.rails-default-error-page div.dialog > div {
22+
border: 1px solid #CCC;
23+
border-right-color: #999;
24+
border-left-color: #999;
25+
border-bottom-color: #BBB;
26+
border-top: #B00100 solid 4px;
27+
border-top-left-radius: 9px;
28+
border-top-right-radius: 9px;
29+
background-color: white;
30+
padding: 7px 12% 0;
31+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32+
}
33+
34+
.rails-default-error-page h1 {
35+
font-size: 100%;
36+
color: #730E15;
37+
line-height: 1.5em;
38+
}
39+
40+
.rails-default-error-page div.dialog > p {
41+
margin: 0 0 1em;
42+
padding: 1em;
43+
background-color: #F7F7F7;
44+
border: 1px solid #CCC;
45+
border-right-color: #999;
46+
border-left-color: #999;
47+
border-bottom-color: #999;
48+
border-bottom-left-radius: 4px;
49+
border-bottom-right-radius: 4px;
50+
border-top-color: #DADADA;
51+
color: #666;
52+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53+
}
54+
</style>
55+
</head>
56+
57+
<body class="rails-default-error-page">
58+
<!-- This file lives in public/503.html -->
59+
<div class="dialog">
60+
<div>
61+
<h1>This page took too long to load.</h1>
62+
</div>
63+
<p>Give it another shot.</p>
64+
</div>
65+
</body>
66+
</html>
File renamed without changes.

0 commit comments

Comments
 (0)