Release the entire env
This commit is contained in:
parent
bbfce29ba8
commit
31f1ec59a7
|
@ -23,6 +23,6 @@ warmup do |app|
|
|||
end
|
||||
|
||||
map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do
|
||||
use Gitlab::ReleaseController
|
||||
use Gitlab::Middleware::ReleaseEnv
|
||||
run Gitlab::Application
|
||||
end
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
module Gitlab
|
||||
module Middleware
|
||||
ReleaseController = Struct.new(:app) do
|
||||
def call(env)
|
||||
app.call(env).tap { env.delete('action_controller.instance') }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
module Gitlab
|
||||
module Middleware
|
||||
# Some of middleware would hold env for no good reason even after the
|
||||
# request had already been processed, and we could not garbage collect
|
||||
# them due to this. Put this middleware as the first middleware so that
|
||||
# it would clear the env after the request is done, allowing GC gets a
|
||||
# chance to release memory for the last request.
|
||||
ReleaseEnv = Struct.new(:app) do
|
||||
def call(env)
|
||||
app.call(env).tap { env.clear }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Middleware::ReleaseController do
|
||||
describe Gitlab::Middleware::ReleaseEnv do
|
||||
let(:inner_app) { double(:app) }
|
||||
let(:app) { described_class.new(inner_app) }
|
||||
let(:env) { { 'action_controller.instance' => 'something' } }
|
Loading…
Reference in New Issue