diff --git a/images/base/entrypoint.sh b/images/base/entrypoint.sh index ec6582f..1eac5ed 100755 --- a/images/base/entrypoint.sh +++ b/images/base/entrypoint.sh @@ -1,64 +1,68 @@ #!/bin/bash set -e source /srv/softwareheritage/utils/pgsql.sh # generate the config file from the 'template' if [ -f /etc/softwareheritage/config.yml.tmpl ]; then # I know... I know! eval "echo \"`cat /etc/softwareheritage/config.yml.tmpl`\"" > \ /etc/softwareheritage/config.yml fi # generate the pgservice file if any if [ -f /run/secrets/postgres-password ]; then POSTGRES_PASSWORD_FILE=/run/secrets/postgres-password setup_pgsql fi # For debugging purpose echo "### CONFIG FILE ###" -cat /etc/softwareheritage/config.yml +cat /etc/softwareheritage/config.yml | grep -v password echo "###################" echo "Arguments: $@" case "$1" in "shell") exec bash -i ;; "objstorage") echo "Starting the SWH $1 RPC server" exec gunicorn3 \ --bind 0.0.0.0:${PORT:-5000} \ --bind unix:/var/run/gunicorn/swh/$1.sock \ --worker-class aiohttp.worker.GunicornWebWorker \ - --threads 4 \ - --workers 2 \ + --threads ${GUNICORN_THREADS:-4} \ + --workers ${GUNICORN_WORKERS:-16} \ --log-level "${LOG_LEVEL:-WARNING}" \ - --timeout 3600 \ + --timeout ${GUNICORN_TIMEOUT:-3600} \ + --statsd-host=prometheus-statsd-exporter:9125 \ + --statsd-prefix=service.app.objstorage \ "swh.$1.api.server:make_app_from_configfile()" ;; *) wait_pgsql template1 echo Database setup if ! check_pgsql_db_created; then echo Creating database and extensions... swh db create --db-name ${POSTGRES_DB} storage fi echo Initializing the database... swh db init --db-name ${POSTGRES_DB} --flavor ${FLAVOR:-default} storage echo "Starting the SWH $1 RPC server" exec gunicorn3 \ --bind 0.0.0.0:${PORT:-5000} \ --bind unix:/var/run/gunicorn/swh/$1.sock \ - --threads 4 \ - --workers 2 \ + --threads ${GUNICORN_THREADS:-4} \ + --workers ${GUNICORN_WORKERS:-16} \ --log-level "${LOG_LEVEL:-WARNING}" \ - --timeout 3600 \ + --timeout ${GUNICORN_TIMEOUT:-3600} \ + --statsd-host=prometheus-statsd-exporter:9125 \ + --statsd-prefix=service.app.storage \ "swh.$1.api.server:make_app_from_configfile()" ;; esac diff --git a/images/replayer/entrypoint.sh b/images/replayer/entrypoint.sh old mode 100644 new mode 100755 index be451f5..f53435f --- a/images/replayer/entrypoint.sh +++ b/images/replayer/entrypoint.sh @@ -1,32 +1,32 @@ #!/bin/bash set -e # generate the config file from the 'template' if [ -f /etc/softwareheritage/config.yml.tmpl ]; then - # I know... I know! - eval "echo \"`cat /etc/softwareheritage/config.yml.tmpl`\"" > \ - /etc/softwareheritage/config.yml + # I know... I know! + eval "echo \"`cat /etc/softwareheritage/config.yml.tmpl`\"" > \ + /etc/softwareheritage/config.yml fi # For debugging purpose echo "### CONFIG FILE ###" cat /etc/softwareheritage/config.yml echo "###################" case "$1" in "shell"|"sh"|"bash") exec bash -i ;; "graph-replayer") - wait-for-it storage:5002 + wait-for-it storage:5002 echo "Starting the SWH mirror graph replayer" exec swh --log-level ${LOG_LEVEL:-WARNING} storage replay ;; "content-replayer") - wait-for-it objstorage:5003 + wait-for-it objstorage:5003 echo "Starting the SWH mirror content replayer" exec swh --log-level ${LOG_LEVEL:-WARNING} objstorage replay ;; esac diff --git a/images/web/entrypoint.sh b/images/web/entrypoint.sh index e4d61a7..531a1bd 100755 --- a/images/web/entrypoint.sh +++ b/images/web/entrypoint.sh @@ -1,53 +1,55 @@ #!/bin/bash set -e source /srv/softwareheritage/utils/pgsql.sh # generate the pgservice file if any if [ -f /run/secrets/postgres-password ]; then - POSTGRES_PASSWORD_FILE=/run/secrets/postgres-password - setup_pgsql + POSTGRES_PASSWORD_FILE=/run/secrets/postgres-password + setup_pgsql fi if [ "$1" = 'shell' ] ; then - shift - if (( $# == 0)); then - exec bash -i - else - "$@" - fi + shift + if (( $# == 0)); then + exec bash -i + else + "$@" + fi else wait_pgsql - create_admin_script=" + create_admin_script=" from django.contrib.auth import get_user_model; username = 'admin'; password = 'admin'; email = 'admin@swh-web.org'; User = get_user_model(); if not User.objects.filter(username = username).exists(): User.objects.create_superuser(username, email, password); " echo "Migrating db using ${DJANGO_SETTINGS_MODULE}" django-admin migrate --settings=${DJANGO_SETTINGS_MODULE} echo "Creating admin user" echo "$create_admin_script" | python3 -m swh.web.manage shell - echo "starting the swh-web server" - mkdir -p /var/run/gunicorn/swh/web + echo "starting the swh-web server" + mkdir -p /var/run/gunicorn/swh/web gunicorn3 \ - --bind 0.0.0.0:5004 \ + --bind 0.0.0.0:5004 \ --bind unix:/var/run/gunicorn/swh/web/sock \ --threads 2 \ --workers 2 \ --timeout 3600 \ --access-logfile '-' \ --config 'python:swh.web.gunicorn_config' \ + --statsd-host=prometheus-statsd-exporter:9125 \ + --statsd-prefix=service.app.web \ 'django.core.wsgi:get_wsgi_application()' fi