diff --git a/admin_cohort/settings.py b/admin_cohort/settings.py index 1a628165..5943dd7a 100644 --- a/admin_cohort/settings.py +++ b/admin_cohort/settings.py @@ -61,6 +61,7 @@ logging.captureWarnings(True) +SOCKET_LOGGER_HOST = env("SOCKET_LOGGER_URL", default="localhost") LOGGING = dict(version=1, disable_existing_loggers=False, loggers={ @@ -89,14 +90,14 @@ 'info': { 'level': "INFO", 'class': "admin_cohort.tools.logging.CustomSocketHandler", - 'host': "localhost", + 'host': SOCKET_LOGGER_HOST, 'port': DEFAULT_TCP_LOGGING_PORT, 'filters': ["request_headers_interceptor"] }, 'error': { 'level': "ERROR", 'class': "admin_cohort.tools.logging.CustomSocketHandler", - 'host': "localhost", + 'host': SOCKET_LOGGER_HOST, 'port': DEFAULT_TCP_LOGGING_PORT, 'filters': ["request_headers_interceptor"] }, diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 58efbb2a..3f09fe95 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -4,9 +4,12 @@ WITH_CELERY_BEAT="" WITH_KERBEROS=false WITH_INIT=false +WITH_LOGGING=false +WITHOUT_APP_SERVER=false +WITH_DB_MIGRATION=false # Parse options using getopts -while getopts "bki" opt; do +while getopts "bkilnd" opt; do case $opt in b) WITH_CELERY_BEAT="-B" @@ -17,6 +20,15 @@ while getopts "bki" opt; do i) WITH_INIT=true ;; + l) + WITH_LOGGING=true + ;; + n) + WITHOUT_APP_SERVER=true + ;; + d) + WITH_DB_MIGRATION=true + ;; \?) echo "Invalid option: -$OPTARG" >&2 usage @@ -40,8 +52,11 @@ sed -i s/{{BACK_HOST}}/"$BACK_HOST"/g /etc/nginx/nginx.conf; service nginx restart source $VIRTUAL_ENV/bin/activate -python manage.py migrate --database="default" -python manage.py collectstatic --noinput + +if [ "$WITH_DB_MIGRATION" = true ]; then + python manage.py migrate --database="default" + python manage.py collectstatic --noinput +fi if [ "$WITH_INIT" = true ]; then set +e @@ -56,16 +71,21 @@ if [ "$WITH_KERBEROS" = true ]; then cron fi -celery -A admin_cohort worker $WITH_CELERY_BEAT --loglevel=INFO --logfile=/app/log/celery.log & -sleep 5 +if [ "$WITH_LOGGING" = true ]; then + python setup_logging.py & +fi + +if [ "$WITHOUT_APP_SERVER" = false ]; then + celery -A admin_cohort worker $WITH_CELERY_BEAT --loglevel=INFO --logfile=/app/log/celery.log & + sleep 5 -python setup_logging.py & -# For websockets -daphne -p 8005 admin_cohort.asgi:application & + # For websockets + daphne -p 8005 admin_cohort.asgi:application & -gunicorn admin_cohort.wsgi --config .conf/gunicorn.conf.py + gunicorn admin_cohort.wsgi --config .conf/gunicorn.conf.py -tail -f /app/log/django.error.log + tail -f /app/log/django.error.log +fi # Wait for any process to exit wait -n