Commit f032f8db authored by Robert Speicher's avatar Robert Speicher

Merge branch 'sh-update-unicorn-rb-example' into 'master'

Clean up stale Prometheus metrics in before_exec unicorn hook

See merge request gitlab-org/gitlab-ce!19683
parents bf3cf66c e9d4b08d
......@@ -81,6 +81,17 @@ GC.respond_to?(:copy_on_write_friendly=) and
# fast LAN.
check_client_connection false
before_exec do |server|
# The following is necessary to ensure stale Prometheus metrics don't
# accumulate over time. It needs to be done in this hook as opposed to
# inside an init script to ensure metrics files aren't deleted after new
# unicorn workers start after a SIGUSR2 is received.
if ENV['prometheus_multiproc_dir']
old_metrics = Dir[File.join(ENV['prometheus_multiproc_dir'], '*.db')]
FileUtils.rm_rf(old_metrics)
end
end
before_fork do |server, worker|
# the following is highly recommended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
......
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