gitlab-org--gitlab-foss/config.ru
Lin Jen-Shin e202fe8c76 Warm up the app so it's fast for the 1st request
This would make the application considered ready much slower,
but when it's ready, then it's really ready. Before this change,
it claims to be ready, but it's annoyingly slow for the first
request with GDK. It's 100% 502 for me, for the first request.

This shouldn't really affect production or so, because if it's
really ready, it should be blazingly fast, and it should not
slow things down too much.

The culprit here is probably `ActionController::Base.helpers.asset_path`
but this could make sure that anything else would load first, too.
2017-12-28 21:55:34 +08:00

27 lines
699 B
Ruby

# This file is used by Rack-based servers to start the application.
if defined?(Unicorn)
require 'unicorn'
if ENV['RAILS_ENV'] == 'production' || ENV['RAILS_ENV'] == 'staging'
# Unicorn self-process killer
require 'unicorn/worker_killer'
min = (ENV['GITLAB_UNICORN_MEMORY_MIN'] || 300 * 1 << 20).to_i
max = (ENV['GITLAB_UNICORN_MEMORY_MAX'] || 350 * 1 << 20).to_i
# Max memory size (RSS) per worker
use Unicorn::WorkerKiller::Oom, min, max
end
end
require ::File.expand_path('../config/environment', __FILE__)
warmup do |app|
client = Rack::MockRequest.new(app)
client.get('/')
end
map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do
run Gitlab::Application
end