Skip to content

Commit

Permalink
Call api by specific entrypoint
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
mdellweg committed Aug 21, 2023
1 parent 6e75c9e commit df01930
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 22 deletions.
13 changes: 10 additions & 3 deletions images/assets/pulp-api
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,19 @@ if [ -n "${PULP_ADMIN_PASSWORD}" ]; then
fi
set -x

if which pulpcore-api
then
PULP_API_ENTRYPOINT="pulpcore-api"
else
PULP_API_ENTRYPOINT="gunicorn pulpcore.app.wsgi:application --bind '127.0.0.1:24817' --name pulp-api --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\\\"\""
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 \
--name pulp-api \
exec ${PULP_API_ENTRYPOINT} \
--timeout "${PULP_GUNICORN_TIMEOUT}" \
--workers "${PULP_API_WORKERS}"
--workers "${PULP_API_WORKERS}" \
--access-logfile -
12 changes: 8 additions & 4 deletions images/assets/pulp-content
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
/usr/bin/wait_on_postgres.py
/usr/bin/wait_on_database_migrations.sh

if which pulpcore-content
then
PULP_CONTENT_ENTRYPOINT="pulpcore-content"
else
PULP_CONTENT_ENTRYPOINT="gunicorn pulpcore.content:server --worker-class aiohttp.GunicornWebWorker --name pulp-content --bind '[::]:24816'"
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 pulpcore.content:server \
--name pulp-content \
--bind '[::]:24816' \
--worker-class 'aiohttp.GunicornWebWorker' \
exec ${PULP_CONTENT_ENTRYPOINT} \
--timeout "${PULP_GUNICORN_TIMEOUT}" \
--workers "${PULP_CONTENT_WORKERS}" \
--access-logfile -
17 changes: 4 additions & 13 deletions images/assets/pulp-worker
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 13 additions & 1 deletion images/s6_assets/init/pulpcore-api
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,16 @@ 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_ENTRYPOINT="pulpcore-api"
else
PULP_API_ENTRYPOINT="gunicorn pulpcore.app.wsgi:application --bind '127.0.0.1:24817' --name pulp-api --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\\\"\""
fi

exec ${OTEL_PREFIX} ${PULP_API_ENTRYPOINT} \
--timeout "${PULP_GUNICORN_TIMEOUT}" \
--workers "${PULP_API_WORKERS}" \
--access-logfile - \
${PULP_GUNICORN_RELOAD_STRING}
14 changes: 13 additions & 1 deletion images/s6_assets/init/pulpcore-content
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,16 @@ fi
if [ "${PULP_OTEL_ENABLED}" = "true" ]; then
OTEL_PREFIX="/usr/local/bin/opentelemetry-instrument --service_name pulp-content"
fi
exec $OTEL_PREFIX /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 - ${PULP_GUNICORN_RELOAD_STRING}

if which pulpcore-content
then
PULP_CONTENT_ENTRYPOINT="pulpcore-content"
else
PULP_CONTENT_ENTRYPOINT="gunicorn pulpcore.content:server --worker-class aiohttp.GunicornWebWorker --name pulp-content --bind '[::]:24816'"
fi

exec ${OTEL_PREFIX} ${PULP_CONTENT_ENTRYPOINT} \
--timeout "${PULP_GUNICORN_TIMEOUT}" \
--workers "${PULP_CONTENT_WORKERS}" \
--access-logfile - \
${PULP_GUNICORN_RELOAD_STRING}

0 comments on commit df01930

Please sign in to comment.