You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/multiprocess/_index.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,22 @@ The `PROMETHEUS_MULTIPROC_DIR` environment variable must be set to a directory
32
32
that the client library can use for metrics. This directory must be wiped
33
33
between process/Gunicorn runs (before startup is recommended).
34
34
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
+
35
51
This environment variable should be set from a start-up shell script,
36
52
and not directly from Python (otherwise it may not propagate to child processes).
0 commit comments