gitlab-org--gitlab-foss/lib/prometheus/cleanup_multiproc_dir_service.rb
Aleksei Lipniagov dcfaf49550 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
2019-08-19 12:52:07 +00:00

23 lines
485 B
Ruby

# 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