debian-mirror-gitlab/lib/prometheus/cleanup_multiproc_dir_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
369 B
Ruby
Raw Permalink Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
module Prometheus
class CleanupMultiprocDirService
2022-06-21 17:19:12 +05:30
def initialize(metrics_dir)
@metrics_dir = metrics_dir
2019-12-04 20:38:33 +05:30
end
2022-06-21 17:19:12 +05:30
def execute
return if @metrics_dir.blank?
2019-12-04 20:38:33 +05:30
2022-06-21 17:19:12 +05:30
files_to_delete = Dir[File.join(@metrics_dir, '*.db')]
return if files_to_delete.blank?
2019-12-04 20:38:33 +05:30
2022-06-21 17:19:12 +05:30
FileUtils.rm_rf(files_to_delete)
2019-12-04 20:38:33 +05:30
end
end
end