Skip to content

Commit af766ef

Browse files
committed
docs: clarify cleaning PROMETHEUS_MULTIPROC_DIR
Signed-off-by: Ayush Anand <ayushanand293@gmail.com>
1 parent 130a4e8 commit af766ef

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

docs/content/multiprocess/_index.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@ The `PROMETHEUS_MULTIPROC_DIR` environment variable must be set to a directory
3232
that the client library can use for metrics. This directory must be wiped
3333
between process/Gunicorn runs (before startup is recommended).
3434

35+
## Cleaning `PROMETHEUS_MULTIPROC_DIR`
36+
37+
The multiprocess directory is not cleaned automatically. If it is not wiped before startup, stale files from a previous run can lead to incorrect metrics.
38+
39+
A common pattern is to wipe and recreate the directory in your process manager/entrypoint script **before** starting Gunicorn/workers:
40+
41+
```bash
42+
rm -rf "$PROMETHEUS_MULTIPROC_DIR"
43+
mkdir -p "$PROMETHEUS_MULTIPROC_DIR"
44+
```
45+
46+
Notes:
47+
- Only wipe a directory that is dedicated to multiprocess metric files.
48+
- In containerized deployments, `PROMETHEUS_MULTIPROC_DIR` is often set to a dedicated path such as `/tmp/prometheus_multiproc_dir`.
49+
- If you run multiple independent apps on the same machine, each should use a separate multiprocess directory.
50+
3551
This environment variable should be set from a start-up shell script,
3652
and not directly from Python (otherwise it may not propagate to child processes).
3753

0 commit comments

Comments
 (0)