Skip to content

Commit

Permalink
Merge pull request #433 from mikedep333/3.21_364_backport_env_vars
Browse files Browse the repository at this point in the history
3.21: Add gunicorn env vars (timeout and # of workers)
  • Loading branch information
dkliban committed Feb 13, 2023
2 parents a7f0f9a + 0557017 commit d56699b
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES/403.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added environment vars to specify gunicorn timeout and number of workers.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ This directory contains assets and tooling for building a variety of Pulp 3 rela

For instructions how to run and use this container, see [Pulp in One Container](https://pulpproject.org/pulp-in-one-container/).

## Advanced Usage Instructions

### Available Environment Variables

The following environment variables configure the container's behavior.

* `PULP_GUNICORN_TIMEOUT` A positive integer that specifies the [timeout for gunicorn process](https://docs.gunicorn.org/en/stable/settings.html#timeout). Default to 90.

* `PULP_API_WORKERS` A positive integer that specifies the number of [gunicorn worker processes](https://docs.gunicorn.org/en/stable/settings.html#workers) for handling Pulp API requests. Default to 2.

* `PULP_CONTENT_WORKERS` A positive integer that specifies the number of [gunicorn worker processes](https://docs.gunicorn.org/en/stable/settings.html#workers) for handling Pulp Content requests. Default to 2.


To add one of them, modify the command you use to start pulp to include syntax like the following at the beginning: Instead of `podman run`, specify `podman run -e PULP_GUNICORN_TIMEOUT=30 ...`

# Build instructions

```bash
Expand Down
3 changes: 3 additions & 0 deletions images/Containerfile.core.base
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ ENV DJANGO_SETTINGS_MODULE=pulpcore.app.settings
ENV PULP_SETTINGS=/etc/pulp/settings.py
ENV _BUILDAH_STARTED_IN_USERNS=""
ENV BUILDAH_ISOLATION=chroot
ENV PULP_GUNICORN_TIMEOUT=${PULP_GUNICORN_TIMEOUT:-90}
ENV PULP_API_WORKERS=${PULP_API_WORKERS:-2}
ENV PULP_CONTENT_WORKERS=${PULP_CONTENT_WORKERS:-2}

# The Fedora 30 image already has tsflags=nodocs set in dnf.conf
#
Expand Down
3 changes: 0 additions & 3 deletions images/assets/pulp-api
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ if [ -n "${PULP_ADMIN_PASSWORD}" ]; then
fi
set -x

PULP_GUNICORN_TIMEOUT=${PULP_GUNICORN_TIMEOUT:-90}
PULP_API_WORKERS=${PULP_API_WORKERS:-2}

mkdir -p /var/lib/pulp/media \
/var/lib/pulp/assets \
/var/lib/pulp/tmp
Expand Down
3 changes: 0 additions & 3 deletions images/assets/pulp-content
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
/usr/bin/wait_on_postgres.py
/usr/bin/wait_on_database_migrations.sh

PULP_GUNICORN_TIMEOUT=${PULP_GUNICORN_TIMEOUT:-90}
PULP_CONTENT_WORKERS=${PULP_CONTENT_WORKERS:-2}

# NOTE: Due to the Linux dual-stack functionality, this will listen on both IPv4
# IPv6, even though netstat may seem to indicate it is IPv6 only.
# Due to containers using network namespaces, even if the host has this disabled
Expand Down
5 changes: 4 additions & 1 deletion s6_images/assets/s6-rc.d/pulpcore-api/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
foreground {
/database/assets/wait_on_database_migrations.sh
}
with-contenv
foreground {
export DJANGO_SETTINGS_MODULE pulpcore.app.settings
export PULP_CONTENT_ORIGIN localhost
/usr/local/bin/pulpcore-manager collectstatic --clear --noinput --link
}
export DJANGO_SETTINGS_MODULE pulpcore.app.settings
export PULP_SETTINGS /etc/pulp/settings.py
/usr/local/bin/gunicorn pulpcore.app.wsgi:application --bind "127.0.0.1:24817" --name pulp-api --timeout 90 --access-logfile - --access-logformat "pulp [%({correlation-id}o)s]: %(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\""
importas PULP_GUNICORN_TIMEOUT PULP_GUNICORN_TIMEOUT
importas PULP_API_WORKERS PULP_API_WORKERS
/usr/local/bin/gunicorn pulpcore.app.wsgi:application --bind "127.0.0.1:24817" --name pulp-api --timeout "${PULP_GUNICORN_TIMEOUT}" --workers "${PULP_API_WORKERS}" --access-logfile - --access-logformat "pulp [%({correlation-id}o)s]: %(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\""
5 changes: 4 additions & 1 deletion s6_images/assets/s6-rc.d/pulpcore-content/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
foreground {
/database/assets/wait_on_database_migrations.sh
}
with-contenv
export DJANGO_SETTINGS_MODULE pulpcore.app.settings
export PULP_SETTINGS /etc/pulp/settings.py
/usr/local/bin/gunicorn pulpcore.content:server --bind "127.0.0.1:24816" --name pulp-content --timeout 90 --worker-class "aiohttp.GunicornWebWorker" -w 2 --access-logfile -
importas PULP_GUNICORN_TIMEOUT PULP_GUNICORN_TIMEOUT
importas PULP_CONTENT_WORKERS PULP_CONTENT_WORKERS
/usr/local/bin/gunicorn pulpcore.content:server --bind "127.0.0.1:24816" --name pulp-content --timeout "${PULP_GUNICORN_TIMEOUT}" --worker-class "aiohttp.GunicornWebWorker" --workers "${PULP_CONTENT_WORKERS}" --access-logfile -
1 change: 1 addition & 0 deletions s6_images/assets/s6-rc.d/pulpcore-worker@1/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
foreground {
/database/assets/wait_on_database_migrations.sh
}
with-contenv
export DJANGO_SETTINGS_MODULE pulpcore.app.settings
export PULP_SETTINGS /etc/pulp/settings.py
export PATH /usr/local/bin:/usr/bin/
Expand Down
1 change: 1 addition & 0 deletions s6_images/assets/s6-rc.d/pulpcore-worker@2/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
foreground {
/database/assets/wait_on_database_migrations.sh
}
with-contenv
export DJANGO_SETTINGS_MODULE pulpcore.app.settings
export PULP_SETTINGS /etc/pulp/settings.py
export PATH /usr/local/bin:/usr/bin/
Expand Down
3 changes: 3 additions & 0 deletions s6_images/pulp_ci_centos/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ ENV DJANGO_SETTINGS_MODULE=pulpcore.app.settings
ENV PULP_SETTINGS=/etc/pulp/settings.py
ENV _BUILDAH_STARTED_IN_USERNS=""
ENV BUILDAH_ISOLATION=chroot
ENV PULP_GUNICORN_TIMEOUT=${PULP_GUNICORN_TIMEOUT:-90}
ENV PULP_API_WORKERS=${PULP_API_WORKERS:-2}
ENV PULP_CONTENT_WORKERS=${PULP_CONTENT_WORKERS:-2}

ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=1
# Needed because otherwise all services must start within 5 seconds
Expand Down

0 comments on commit d56699b

Please sign in to comment.