2019-08-19 08:52:07 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Prometheus
|
|
|
|
class CleanupMultiprocDirService
|
2022-03-25 08:07:52 -04:00
|
|
|
def initialize(metrics_dir)
|
|
|
|
@metrics_dir = metrics_dir
|
2019-08-19 08:52:07 -04:00
|
|
|
end
|
|
|
|
|
2022-03-25 08:07:52 -04:00
|
|
|
def execute
|
|
|
|
return if @metrics_dir.blank?
|
2019-08-19 08:52:07 -04:00
|
|
|
|
2022-03-25 08:07:52 -04:00
|
|
|
files_to_delete = Dir[File.join(@metrics_dir, '*.db')]
|
|
|
|
return if files_to_delete.blank?
|
2019-08-19 08:52:07 -04:00
|
|
|
|
2022-03-25 08:07:52 -04:00
|
|
|
FileUtils.rm_rf(files_to_delete)
|
2019-08-19 08:52:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|