diff options
author | Aleksei Lipniagov <alipniagov@gitlab.com> | 2019-08-19 12:52:07 +0000 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-08-19 12:52:07 +0000 |
commit | dcfaf49550866a291c316f2901e4274d587e7d37 (patch) | |
tree | b6e6e436383ad699d85720542463ebe63098bf9d /lib | |
parent | 1d604d490960102ec9c6692a304015cd344319cd (diff) | |
download | gitlab-ce-dcfaf49550866a291c316f2901e4274d587e7d37.tar.gz |
Clean Sidekiq metrics from multiproc dir on start
After moving the multiproc dir cleanup into `config.ru`:`warmup`, we
stopped cleaning Sidekiq metrics dir which is not correct.
This MR intended to fix that. More details:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31668
Diffstat (limited to 'lib')
-rw-r--r-- | lib/prometheus/cleanup_multiproc_dir_service.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/prometheus/cleanup_multiproc_dir_service.rb b/lib/prometheus/cleanup_multiproc_dir_service.rb new file mode 100644 index 00000000000..6418b4de166 --- /dev/null +++ b/lib/prometheus/cleanup_multiproc_dir_service.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Prometheus + class CleanupMultiprocDirService + include Gitlab::Utils::StrongMemoize + + def execute + FileUtils.rm_rf(old_metrics) if old_metrics + end + + private + + def old_metrics + strong_memoize(:old_metrics) do + Dir[File.join(multiprocess_files_dir, '*.db')] if multiprocess_files_dir + end + end + + def multiprocess_files_dir + ::Prometheus::Client.configuration.multiprocess_files_dir + end + end +end |