From 31641975ddfae325203f3109a527e163e2ac4f9d Mon Sep 17 00:00:00 2001 From: trent-codecov Date: Wed, 1 Jan 2025 12:26:48 -0500 Subject: [PATCH 1/3] Update config for gunicorn --- prod.sh | 12 ++++++++---- staging.sh | 15 +++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/prod.sh b/prod.sh index 575b65f5ae..1dee61539e 100755 --- a/prod.sh +++ b/prod.sh @@ -7,8 +7,12 @@ if [ -f "/usr/local/bin/berglas" ]; then prefix="berglas exec --" fi -export PROMETHEUS_MULTIPROC_DIR="${PROMETHEUS_MULTIPROC_DIR:-$HOME/.prometheus}" -rm -r ${PROMETHEUS_MULTIPROC_DIR?}/* 2> /dev/null -mkdir -p "$PROMETHEUS_MULTIPROC_DIR" +GUNICORN_WORKERS=${GUNICORN_WORKERS:-2} +if [ "$GUNICORN_WORKERS" -gt 1 ]; +then + export PROMETHEUS_MULTIPROC_DIR="${PROMETHEUS_MULTIPROC_DIR:-$HOME/.prometheus}" + rm -r ${PROMETHEUS_MULTIPROC_DIR?}/* 2> /dev/null + mkdir -p "$PROMETHEUS_MULTIPROC_DIR" +fi -$prefix gunicorn codecov.wsgi:application --workers=2 --bind 0.0.0.0:8000 --access-logfile '-' --statsd-host ${STATSD_HOST}:${STATSD_PORT} --timeout "${GUNICORN_TIMEOUT:-600}" +$prefix gunicorn codecov.wsgi:application --workers=${GUNICORN_WORKERS} --bind 0.0.0.0:8000 --access-logfile '-' --statsd-host ${STATSD_HOST}:${STATSD_PORT} --timeout "${GUNICORN_TIMEOUT:-600}" --disable-redirect-access-to-syslog --max-requests=50000 --max-requests-jitter=300 diff --git a/staging.sh b/staging.sh index 1b68b944a0..4e70c984d0 100644 --- a/staging.sh +++ b/staging.sh @@ -8,13 +8,12 @@ prefix="" if [ -f "/usr/local/bin/berglas" ]; then prefix="berglas exec --" fi -suffix="" -if [[ "$STATSD_HOST" ]]; then - suffix="--statsd-host ${STATSD_HOST}:${STATSD_PORT}" -fi -export PROMETHEUS_MULTIPROC_DIR="${PROMETHEUS_MULTIPROC_DIR:-$HOME/.prometheus}" -rm -r ${PROMETHEUS_MULTIPROC_DIR?}/* 2> /dev/null -mkdir -p "$PROMETHEUS_MULTIPROC_DIR" +if [ "$GUNICORN_WORKERS" -gt 1 ]; +then + export PROMETHEUS_MULTIPROC_DIR="${PROMETHEUS_MULTIPROC_DIR:-$HOME/.prometheus}" + rm -r ${PROMETHEUS_MULTIPROC_DIR?}/* 2> /dev/null + mkdir -p "$PROMETHEUS_MULTIPROC_DIR" +fi -$prefix gunicorn codecov.wsgi:application --reload --workers=2 --bind 0.0.0.0:8000 --access-logfile '-' --timeout "${GUNICORN_TIMEOUT:-600}" $suffix +$prefix gunicorn codecov.wsgi:application --reload --workers=${GUNICORN_WORKERS:-2} --bind 0.0.0.0:8000 --access-logfile '-' --timeout "${GUNICORN_TIMEOUT:-600}" --disable-redirect-access-to-syslog --config=gunicorn.conf.py From 9962acc56c42539c885dda3dd759afbb55519acc Mon Sep 17 00:00:00 2001 From: trent-codecov Date: Wed, 1 Jan 2025 12:30:24 -0500 Subject: [PATCH 2/3] Update config for gunicorn --- enterprise.sh | 2 +- prod.sh | 2 +- staging.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/enterprise.sh b/enterprise.sh index d0a29bce42..22b1c8659f 100755 --- a/enterprise.sh +++ b/enterprise.sh @@ -31,7 +31,7 @@ then python manage.py migrate python manage.py migrate --database "timeseries" timeseries # Start api - ${SUB}$prefix gunicorn codecov.wsgi:application --workers=$GUNICORN_WORKERS --bind ${CODECOV_API_BIND:-0.0.0.0}:${CODECOV_API_PORT:-8000} --access-logfile '-' ${statsd}--timeout "${GUNICORN_TIMEOUT:-600}"${POST} + ${SUB}$prefix gunicorn codecov.wsgi:application --workers=$GUNICORN_WORKERS --threads=${GUNICORN_THREADS:-1} --bind ${CODECOV_API_BIND:-0.0.0.0}:${CODECOV_API_PORT:-8000} --access-logfile '-' ${statsd}--timeout "${GUNICORN_TIMEOUT:-600}"${POST} elif [[ "$1" = "rti" ]]; then # Start api diff --git a/prod.sh b/prod.sh index 1dee61539e..63c6d478ee 100755 --- a/prod.sh +++ b/prod.sh @@ -15,4 +15,4 @@ then mkdir -p "$PROMETHEUS_MULTIPROC_DIR" fi -$prefix gunicorn codecov.wsgi:application --workers=${GUNICORN_WORKERS} --bind 0.0.0.0:8000 --access-logfile '-' --statsd-host ${STATSD_HOST}:${STATSD_PORT} --timeout "${GUNICORN_TIMEOUT:-600}" --disable-redirect-access-to-syslog --max-requests=50000 --max-requests-jitter=300 +$prefix gunicorn codecov.wsgi:application --workers=${GUNICORN_WORKERS} --threads=${GUNICORN_THREADS:-1} --bind 0.0.0.0:8000 --access-logfile '-' --statsd-host ${STATSD_HOST}:${STATSD_PORT} --timeout "${GUNICORN_TIMEOUT:-600}" --disable-redirect-access-to-syslog --max-requests=50000 --max-requests-jitter=300 diff --git a/staging.sh b/staging.sh index 4e70c984d0..7448958889 100644 --- a/staging.sh +++ b/staging.sh @@ -16,4 +16,4 @@ then mkdir -p "$PROMETHEUS_MULTIPROC_DIR" fi -$prefix gunicorn codecov.wsgi:application --reload --workers=${GUNICORN_WORKERS:-2} --bind 0.0.0.0:8000 --access-logfile '-' --timeout "${GUNICORN_TIMEOUT:-600}" --disable-redirect-access-to-syslog --config=gunicorn.conf.py +$prefix gunicorn codecov.wsgi:application --reload --workers=${GUNICORN_WORKERS:-2} --threads=${GUNICORN_THREADS:-1} --bind 0.0.0.0:8000 --access-logfile '-' --timeout "${GUNICORN_TIMEOUT:-600}" --disable-redirect-access-to-syslog --config=gunicorn.conf.py From c672e4baef3c6283db765d9c2a07eb8cee82fdcf Mon Sep 17 00:00:00 2001 From: trent-codecov Date: Wed, 1 Jan 2025 12:31:31 -0500 Subject: [PATCH 3/3] Update config for gunicorn --- enterprise.sh | 2 +- prod.sh | 2 +- staging.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/enterprise.sh b/enterprise.sh index 22b1c8659f..c3e78fa813 100755 --- a/enterprise.sh +++ b/enterprise.sh @@ -31,7 +31,7 @@ then python manage.py migrate python manage.py migrate --database "timeseries" timeseries # Start api - ${SUB}$prefix gunicorn codecov.wsgi:application --workers=$GUNICORN_WORKERS --threads=${GUNICORN_THREADS:-1} --bind ${CODECOV_API_BIND:-0.0.0.0}:${CODECOV_API_PORT:-8000} --access-logfile '-' ${statsd}--timeout "${GUNICORN_TIMEOUT:-600}"${POST} + ${SUB}$prefix gunicorn codecov.wsgi:application --workers=$GUNICORN_WORKERS --threads=${GUNICORN_THREADS:-1} --worker-connections=${GUNICORN_WORKER_CONNECTIONS:-1000} --bind ${CODECOV_API_BIND:-0.0.0.0}:${CODECOV_API_PORT:-8000} --access-logfile '-' ${statsd}--timeout "${GUNICORN_TIMEOUT:-600}"${POST} elif [[ "$1" = "rti" ]]; then # Start api diff --git a/prod.sh b/prod.sh index 63c6d478ee..f87719d145 100755 --- a/prod.sh +++ b/prod.sh @@ -15,4 +15,4 @@ then mkdir -p "$PROMETHEUS_MULTIPROC_DIR" fi -$prefix gunicorn codecov.wsgi:application --workers=${GUNICORN_WORKERS} --threads=${GUNICORN_THREADS:-1} --bind 0.0.0.0:8000 --access-logfile '-' --statsd-host ${STATSD_HOST}:${STATSD_PORT} --timeout "${GUNICORN_TIMEOUT:-600}" --disable-redirect-access-to-syslog --max-requests=50000 --max-requests-jitter=300 +$prefix gunicorn codecov.wsgi:application --workers=${GUNICORN_WORKERS} --threads=${GUNICORN_THREADS:-1} --worker-connections=${GUNICORN_WORKER_CONNECTIONS:-1000} --bind 0.0.0.0:8000 --access-logfile '-' --statsd-host ${STATSD_HOST}:${STATSD_PORT} --timeout "${GUNICORN_TIMEOUT:-600}" --disable-redirect-access-to-syslog --max-requests=50000 --max-requests-jitter=300 diff --git a/staging.sh b/staging.sh index 7448958889..cef17032e6 100644 --- a/staging.sh +++ b/staging.sh @@ -16,4 +16,4 @@ then mkdir -p "$PROMETHEUS_MULTIPROC_DIR" fi -$prefix gunicorn codecov.wsgi:application --reload --workers=${GUNICORN_WORKERS:-2} --threads=${GUNICORN_THREADS:-1} --bind 0.0.0.0:8000 --access-logfile '-' --timeout "${GUNICORN_TIMEOUT:-600}" --disable-redirect-access-to-syslog --config=gunicorn.conf.py +$prefix gunicorn codecov.wsgi:application --reload --workers=${GUNICORN_WORKERS:-2} --threads=${GUNICORN_THREADS:-1} --worker-connections=${GUNICORN_WORKER_CONNECTIONS:-1000} --bind 0.0.0.0:8000 --access-logfile '-' --timeout "${GUNICORN_TIMEOUT:-600}" --disable-redirect-access-to-syslog --config=gunicorn.conf.py