summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.ru2
-rw-r--r--lib/gitlab/middleware/release_controller.rb9
-rw-r--r--lib/gitlab/middleware/release_env.rb14
-rw-r--r--spec/lib/gitlab/middleware/release_env_spec.rb (renamed from spec/lib/gitlab/middleware/release_controller_spec.rb)2
4 files changed, 16 insertions, 11 deletions
diff --git a/config.ru b/config.ru
index c4bef72308e..7b15939c6ff 100644
--- a/config.ru
+++ b/config.ru
@@ -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
diff --git a/lib/gitlab/middleware/release_controller.rb b/lib/gitlab/middleware/release_controller.rb
deleted file mode 100644
index a21d718d51c..00000000000
--- a/lib/gitlab/middleware/release_controller.rb
+++ /dev/null
@@ -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
diff --git a/lib/gitlab/middleware/release_env.rb b/lib/gitlab/middleware/release_env.rb
new file mode 100644
index 00000000000..f8d0a135965
--- /dev/null
+++ b/lib/gitlab/middleware/release_env.rb
@@ -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
diff --git a/spec/lib/gitlab/middleware/release_controller_spec.rb b/spec/lib/gitlab/middleware/release_env_spec.rb
index 854bac6e751..657b705502a 100644
--- a/spec/lib/gitlab/middleware/release_controller_spec.rb
+++ b/spec/lib/gitlab/middleware/release_env_spec.rb
@@ -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' } }