#345: fixed: could not obtain a database connection within 5.000 seconds
This commit is contained in:
parent
c87c150bcd
commit
3eda2718f8
|
@ -14,6 +14,11 @@ module Rosa
|
||||||
class Application < Rails::Application
|
class Application < Rails::Application
|
||||||
config.i18n.enforce_available_locales = true
|
config.i18n.enforce_available_locales = true
|
||||||
|
|
||||||
|
unless Rails.env.test?
|
||||||
|
require 'close_ar_connections_middleware'
|
||||||
|
config.middleware.insert_after('Rack::Sendfile', CloseArConnectionsMiddleware)
|
||||||
|
end
|
||||||
|
|
||||||
# Rate limit
|
# Rate limit
|
||||||
config.middleware.insert_before Rack::Runtime, ApiDefender
|
config.middleware.insert_before Rack::Runtime, ApiDefender
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
# "Coffee's for closers"
|
||||||
|
class CloseArConnectionsMiddleware
|
||||||
|
def initialize(app)
|
||||||
|
@app = app
|
||||||
|
end
|
||||||
|
|
||||||
|
def call(env)
|
||||||
|
@app.call(env)
|
||||||
|
ensure
|
||||||
|
ActiveRecord::Base.clear_active_connections! unless env.key?('rack.test')
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue