Skip to content

Commit

Permalink
feat: allow to configure Gunicorn workers
Browse files Browse the repository at this point in the history
  • Loading branch information
MikkCZ authored and rixx committed Mar 27, 2023
1 parent 702197a commit 91b6090
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ This repository contains a docker-compose setup as well as an [ansible](https://
support](https://docs.traefik.io/user-guide/docker-and-lets-encrypt/). An example to copy into the normal compose file
is located at ``reverse-proxy-examples/docker-compose``. You can also find a few words on an nginx configuration at
``reverse-proxy-examples/nginx``
* Optional: To adjust the number of [Gunicorn workers](https://docs.gunicorn.org/en/stable/settings.html#workers), provide
the container with `GUNICORN_WORKERS` environment variable. Similarly you can use `GUNICORN_MAX_REQUESTS` and
`GUNICORN_MAX_REQUESTS_JITTER` to configure the requests a worker instance will process before restarting.
Here's how to set an environment variable [in
`docker-compose.yml`](https://docs.docker.com/compose/environment-variables/set-environment-variables/)
or when using [`docker run` command](https://docs.docker.com/engine/reference/run/#env-environment-variables).
* Run ``docker-compose up -d ``. After a few minutes the setup should be accessible under http://yourdomain.com/orga
* Set up a user and an organizer by running ``docker exec -ti pretalx pretalx init``.
* Set up a cronjob for periodic tasks like this ``15,45 * * * * docker exec pretalx-app pretalx runperiodic``
Expand Down
10 changes: 6 additions & 4 deletions deployment/docker/pretalx.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
cd /pretalx/src
export PRETALX_DATA_DIR=/data
export HOME=/pretalx
export NUM_WORKERS=$((2 * $(nproc --all)))
export GUNICORN_WORKERS="${GUNICORN_WORKERS:-${WEB_CONCURRENCY:-$((2 * $(nproc --all)))}}"
export GUNICORN_MAX_REQUESTS="${GUNICORN_MAX_REQUESTS:-1200}"
export GUNICORN_MAX_REQUESTS_JITTER="${GUNICORN_MAX_REQUESTS_JITTER:-50}"

if [ ! -d /data/logs ]; then
mkdir /data/logs;
Expand All @@ -24,9 +26,9 @@ fi
if [ "$1" == "webworker" ]; then
exec gunicorn pretalx.wsgi \
--name pretalx \
--workers $NUM_WORKERS \
--max-requests 1200 \
--max-requests-jitter 50 \
--workers "${GUNICORN_WORKERS}" \
--max-requests "${GUNICORN_MAX_REQUESTS}" \
--max-requests-jitter "${GUNICORN_MAX_REQUESTS_JITTER}" \
--log-level=info \
--bind=127.0.0.1:80
fi
Expand Down

0 comments on commit 91b6090

Please sign in to comment.