Skip to content

Commit 2f91bbd

Browse files
author
Daniel Magliola
authored
Merge pull request #183 from prometheus/document_startup_file_cleanup
Document how to clean up work dir for DirectFileStore on startup
2 parents 4f8de6c + 209db7c commit 2f91bbd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,19 @@ you store your metric files (specified when initializing the `DirectFileStore`)
368368
when your app starts. Otherwise, each app run will continue exporting the metrics from the
369369
previous run.
370370

371+
If you have this issue, one way to do this is to run code similar to this as part of you
372+
initialization:
373+
374+
```ruby
375+
Dir["#{app_path}/tmp/prometheus/*.bin"].each do |file_path|
376+
File.unlink(file_path)
377+
end
378+
```
379+
380+
If you are running in pre-fork servers (such as Unicorn or Puma with multiple processes),
381+
make sure you do this **before** the server forks. Otherwise, each child process may delete
382+
files created by other processes on *this* run, instead of deleting old files.
383+
371384
**Large numbers of files**: Because there is an individual file per metric and per process
372385
(which is done to optimize for observation performance), you may end up with a large number
373386
of files. We don't currently have a solution for this problem, but we're working on it.

0 commit comments

Comments
 (0)