summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2018-06-12 19:21:47 +0000
committerRobert Speicher <robert@gitlab.com>2018-06-12 19:21:47 +0000
commitf032f8dba6fc95ad89444ed93727dc41f58f02e4 (patch)
tree971b8bf10ed17e90daf897688256d4c73da0d146 /config
parentbf3cf66c0a71564bb3006c269b3104444735d1d2 (diff)
parente9d4b08dc2cde4477e77f5ad4b2e9efad47fbf71 (diff)
downloadgitlab-ce-f032f8dba6fc95ad89444ed93727dc41f58f02e4.tar.gz
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
Diffstat (limited to 'config')
-rw-r--r--config/unicorn.rb.example11
1 files changed, 11 insertions, 0 deletions
diff --git a/config/unicorn.rb.example b/config/unicorn.rb.example
index cc10da2bd88..220a0191160 100644
--- a/config/unicorn.rb.example
+++ b/config/unicorn.rb.example
@@ -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