From abf4163c75883b38d08c178e7b7d59fcb1ac9ee3 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Thu, 10 Aug 2023 13:46:09 +0200 Subject: [PATCH] Call api by specific entrypoint [noissue] --- images/assets/pulp-api | 10 +++++++++- images/assets/pulp-worker | 17 ++++------------- images/s6_assets/init/pulpcore-api | 10 +++++++++- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/images/assets/pulp-api b/images/assets/pulp-api index 4b15f24f..28c4a00a 100755 --- a/images/assets/pulp-api +++ b/images/assets/pulp-api @@ -31,12 +31,20 @@ if [ -n "${PULP_ADMIN_PASSWORD}" ]; then fi set -x +if which pulpcore-api +then + PULP_API_GUNICORN="pulpcore-api" +else + PULP_API_GUNICORN="gunicorn pulpcore.app.wsgi:application" +fi + # 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 # with /proc/sys/net/ipv6/bindv6only=1, the container will still have # it enabled with /proc/sys/net/ipv6/bindv6only=0 . -exec gunicorn --bind '[::]:24817' pulpcore.app.wsgi:application \ +exec ${PULP_API_GUNICORN} \ +--bind '[::]:24817' \ --name pulp-api \ --timeout "${PULP_GUNICORN_TIMEOUT}" \ --workers "${PULP_API_WORKERS}" diff --git a/images/assets/pulp-worker b/images/assets/pulp-worker index 450d8976..6fba4d06 100755 --- a/images/assets/pulp-worker +++ b/images/assets/pulp-worker @@ -3,16 +3,7 @@ /usr/bin/wait_on_postgres.py /usr/bin/wait_on_database_migrations.sh -NEW_TASKING_SYSTEM=$(python3 -c "from packaging.version import parse; from pulpcore.app.apps import PulpAppConfig; print('yes' if parse(PulpAppConfig.version) >= parse('3.13.0.dev0') else 'no')") -echo $NEW_TASKING_SYSTEM - -if [[ "$NEW_TASKING_SYSTEM" == "no" ]]; then - # TODO: Set ${PULP_WORKER_NUMBER} to the Pod Number - # In the meantime, the hostname provides uniqueness. - exec rq worker --url "redis://${REDIS_SERVICE_HOST}:${REDIS_SERVICE_PORT}" -w "pulpcore.tasking.worker.PulpWorker" -c "pulpcore.rqconfig" -else - export DJANGO_SETTINGS_MODULE=pulpcore.app.settings - export PULP_SETTINGS=/etc/pulp/settings.py - export PATH=/usr/local/bin:/usr/bin/ - exec pulpcore-worker -fi +export DJANGO_SETTINGS_MODULE=pulpcore.app.settings +export PULP_SETTINGS=/etc/pulp/settings.py +export PATH=/usr/local/bin:/usr/bin/ +exec /usr/local/bin/pulpcore-worker diff --git a/images/s6_assets/init/pulpcore-api b/images/s6_assets/init/pulpcore-api index 767aba84..8e5826be 100755 --- a/images/s6_assets/init/pulpcore-api +++ b/images/s6_assets/init/pulpcore-api @@ -5,4 +5,12 @@ fi if [ "${PULP_OTEL_ENABLED}" = "true" ]; then OTEL_PREFIX="/usr/local/bin/opentelemetry-instrument --service_name pulp-api" fi -exec $OTEL_PREFIX /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\"" ${PULP_GUNICORN_RELOAD_STRING} + +if which pulpcore-api +then + PULP_API_GUNICORN="pulpcore-api" +else + PULP_API_GUNICORN="gunicorn pulpcore.app.wsgi:application" +fi + +exec ${OTEL_PREFIX} ${PULP_API_GUNICORN} --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\"" ${PULP_GUNICORN_RELOAD_STRING}