Commit 31f1ec59 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Release the entire env

parent bbfce29b
......@@ -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
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
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
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' } }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment