0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-24 18:07:17 +01:00
posthog/bin/docker-server-unit
Frank Hamand 773e20d771
feat: Add prometheus metrics to nginx unit (#18387)
* Add prometheus metrics to nginx unit

* Run multiprocess prom collector in unit

* Refactor unit metrics to use prom client properly

* Ruff
2023-11-07 15:12:03 +00:00

16 lines
595 B
Bash
Executable File

#!/bin/bash
set -e
# To ensure we are able to expose metrics from multiple processes, we need to
# provide a directory for `prometheus_client` to store a shared registry.
export PROMETHEUS_MULTIPROC_DIR=$(mktemp -d)
chmod -R 777 $PROMETHEUS_MULTIPROC_DIR
trap 'rm -rf "$PROMETHEUS_MULTIPROC_DIR"' EXIT
export PROMETHEUS_METRICS_EXPORT_PORT=8001
export STATSD_PORT=${STATSD_PORT:-8125}
# We need to run as --user root so that nginx unit can proxy the control socket for stats
# However each application is run as "nobody"
exec /usr/local/bin/docker-entrypoint.sh unitd --no-daemon --user root