debian-mirror-gitlab/config/initializers/rack_timeout.rb

27 lines
1.2 KiB
Ruby
Raw Normal View History

2019-09-04 21:01:54 +05:30
# frozen_string_literal: true
# Puma doesn't have any timeout mechanism for terminating long-running
# requests, to make sure that server is not paralyzed by long-running
# or stuck queries, we add a request timeout which terminates the
# request after 60 seconds. This may be dangerous in some situations
2022-07-23 23:45:48 +05:30
# (https://github.com/zombocom/rack-timeout/blob/master/doc/exceptions.md)
2019-09-04 21:01:54 +05:30
# and it's used only as the last resort. In such case this termination is
# logged and we should fix the potential timeout issue in the code itself.
2020-03-13 15:44:24 +05:30
if Gitlab::Runtime.puma? && !Rails.env.test?
Rack::Timeout::Logger.level = Logger::ERROR
2019-09-04 21:01:54 +05:30
Gitlab::Application.configure do |config|
config.middleware.insert_before(Rack::Runtime, Rack::Timeout,
2019-09-30 21:07:59 +05:30
service_timeout: ENV.fetch('GITLAB_RAILS_RACK_TIMEOUT', 60).to_i,
wait_timeout: ENV.fetch('GITLAB_RAILS_WAIT_TIMEOUT', 90).to_i)
2019-09-04 21:01:54 +05:30
end
observer = Gitlab::Cluster::RackTimeoutObserver.new
Rack::Timeout.register_state_change_observer(:gitlab_rack_timeout, &observer.callback)
end
2022-08-13 15:12:31 +05:30
unless Gitlab::Utils.to_boolean(ENV['GITLAB_RAILS_RACK_TIMEOUT_ENABLE_LOGGING'], default: true)
Rack::Timeout::Logger.disable
end