0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-27 16:26:50 +01:00
posthog/bin/docker-server
Frank Hamand 7a14421e78
feat: Set keepalive to 60 on gunicorn (#17897)
Set keepalive to 60 on gunicorn

The default is 2 seconds, the default for ALBs is 30 seconds

This can cause a race condition where gunicorn closes the connection
as the ALB sends a request, resulting in a 502.
2023-10-11 08:54:48 +01:00

28 lines
783 B
Bash
Executable File

#!/bin/bash
set -e
./bin/migrate-check
# 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)
trap 'rm -rf "$PROMETHEUS_MULTIPROC_DIR"' EXIT
export PROMETHEUS_METRICS_EXPORT_PORT=8001
export STATSD_PORT=${STATSD_PORT:-8125}
exec gunicorn posthog.wsgi \
--config gunicorn.config.py \
--bind 0.0.0.0:8000 \
--log-file - \
--log-level info \
--access-logfile - \
--worker-tmp-dir /dev/shm \
--workers=2 \
--threads=8 \
--keep-alive=60 \
--backlog=${GUNICORN_BACKLOG:-1000} \
--worker-class=gthread \
${STATSD_HOST:+--statsd-host $STATSD_HOST:$STATSD_PORT} \
--limit-request-line=16384 $@