From fb176cd1b1635cdaa3d16c99ba8e4fd1f314c895 Mon Sep 17 00:00:00 2001 From: Bram van Dartel Date: Fri, 19 Apr 2024 10:43:48 +0200 Subject: [PATCH] Development (#360) * restructured logging to stdout * update datalogger bug (oneshot instead of longrun) --------- Co-authored-by: Bram van Dartel Co-authored-by: Bram van Dartel --- .github/workflows/build_release.yml | 2 +- Dockerfile | 1 - rootfs/etc/s6-overlay/s6-rc.d/init-docker-entrypoint/run | 8 ++++---- .../s6-overlay/s6-rc.d/svc-dsmr-backend-log/dependencies | 1 + rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/run | 4 ++++ rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/type | 1 + rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/up | 1 + .../etc/s6-overlay/s6-rc.d/svc-dsmr-backend/dependencies | 0 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend/run | 4 ++-- .../s6-rc.d/svc-dsmr-datalogger-log/dependencies | 1 + rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/run | 4 ++++ .../etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/type | 1 + rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/up | 1 + .../s6-overlay/s6-rc.d/svc-dsmr-datalogger/dependencies | 0 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/run | 4 ++-- rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/type | 2 +- .../s6-rc.d/svc-dsmr-remote-datalogger/dependencies | 0 .../etc/s6-overlay/s6-rc.d/svc-dsmr-remote-datalogger/run | 4 ++-- .../s6-rc.d/svc-dsmr-webinterface-log/dependencies | 1 + .../etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/run | 4 ++++ .../etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/type | 1 + .../etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/up | 1 + .../s6-overlay/s6-rc.d/svc-dsmr-webinterface/dependencies | 0 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/run | 2 +- rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/type | 2 +- rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/dependencies | 0 rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/run | 3 ++- .../s6-rc.d/user/contents.d/svc-dsmr-backend-log | 0 .../s6-rc.d/user/contents.d/svc-dsmr-datalogger-log | 0 .../s6-rc.d/user/contents.d/svc-dsmr-webinterface-log | 0 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-nginx | 0 31 files changed, 37 insertions(+), 16 deletions(-) create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/dependencies create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/run create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/type create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/up mode change 100644 => 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend/dependencies create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/dependencies create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/run create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/type create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/up mode change 100644 => 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/dependencies mode change 100644 => 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-remote-datalogger/dependencies create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/dependencies create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/run create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/type create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/up mode change 100644 => 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/dependencies mode change 100644 => 100755 rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/dependencies create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-dsmr-backend-log create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-dsmr-datalogger-log create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-dsmr-webinterface-log mode change 100644 => 100755 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-nginx diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index ab76a4a..288f34c 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -24,7 +24,7 @@ concurrency: env: DOCKER_TARGET_REPO: xirixiz/dsmr-reader-docker DOCKERFILE: Dockerfile - DOCKER_TARGET_RELEASE: 2024.04.01 + DOCKER_TARGET_RELEASE: 2024.04.02 jobs: ################################################ diff --git a/Dockerfile b/Dockerfile index 6cbba73..37b927b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,6 @@ ENV QEMU_ARCH=${QEMU_ARCH:-x86_64} \ DSMR_VERSION=${DSMR_VERSION} \ DOCKER_TARGET_RELEASE=${DOCKER_TARGET_RELEASE} \ PIP_NO_CACHE_DIR=1 \ - S6_SERVICES_GRACETIME=30000 \ S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 ENV DJANGO_SECRET_KEY=dsmrreader \ diff --git a/rootfs/etc/s6-overlay/s6-rc.d/init-docker-entrypoint/run b/rootfs/etc/s6-overlay/s6-rc.d/init-docker-entrypoint/run index adb7fcf..45242fd 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/init-docker-entrypoint/run +++ b/rootfs/etc/s6-overlay/s6-rc.d/init-docker-entrypoint/run @@ -187,11 +187,11 @@ function _check_db_availability() { fi if [[ -n "${DJANGO_DATABASE_ENGINE}" ]]; then _info "Verifying database connectivity to host: ${DJANGO_DATABASE_HOST} with port: ${DJANGO_DATABASE_PORT}..." - for i in {1..30}; do - if ! nc -z "${DJANGO_DATABASE_HOST}" "${DJANGO_DATABASE_PORT}"; then + for i in {1..10}; do + if ! nc -z "${DJANGO_DATABASE_HOST}" "${DJANGO_DATABASE_PORT}" > /dev/null 2>&1; then sleep 1 - printf "\\rTesting database connectivity: %s second(s) of 30 seconds..." "$i" - if [[ $i == 30 ]]; then + printf "\\rTesting database connectivity: %s second(s) of 10 seconds..." "$i" + if [[ $i == 10 ]]; then _error "Database connectivity couldn't be verified! Please verify your settings. Exiting..." exit 1 fi diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/dependencies b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/dependencies new file mode 100755 index 0000000..6d20c2a --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/dependencies @@ -0,0 +1 @@ +svc-dsmr-backend \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/run b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/run new file mode 100755 index 0000000..c45f554 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/run @@ -0,0 +1,4 @@ +#!/command/with-contenv bash +# shellcheck shell=bash + +s6-log -bp -- /var/log/dsmr_backend diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/type b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/type new file mode 100755 index 0000000..5883cff --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/type @@ -0,0 +1 @@ +longrun diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/up b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/up new file mode 100755 index 0000000..f055bca --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/run diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend/dependencies b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend/dependencies old mode 100644 new mode 100755 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend/run b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend/run index de0110c..b11c49b 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend/run +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend/run @@ -4,7 +4,7 @@ if [[ "${DSMRREADER_OPERATION_MODE}" = standalone || "${DSMRREADER_OPERATION_MODE}" = api_server ]]; then echo "Starting DSMR Reader - backend..." cd /app || exit - exec s6-setuidgid app /usr/local/bin/python3 -u /app/manage.py dsmr_backend + nice -n 10 s6-setuidgid app /usr/local/bin/python3 -u /app/manage.py dsmr_backend else sleep infinity -fi +fi \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/dependencies b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/dependencies new file mode 100755 index 0000000..13cf561 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/dependencies @@ -0,0 +1 @@ +svc-dsmr-datalogger \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/run b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/run new file mode 100755 index 0000000..f1bcbb2 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/run @@ -0,0 +1,4 @@ +#!/command/with-contenv bash +# shellcheck shell=bash + +s6-log -bp -- /var/log/dsmr_datalogger diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/type b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/type new file mode 100755 index 0000000..5883cff --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/type @@ -0,0 +1 @@ +longrun diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/up b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/up new file mode 100755 index 0000000..3ab742d --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/run diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/dependencies b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/dependencies old mode 100644 new mode 100755 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/run b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/run index e566e45..6d4846f 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/run +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/run @@ -4,7 +4,7 @@ if [[ "${DSMRREADER_OPERATION_MODE}" = standalone ]]; then echo "Starting DSMR Reader - datalogger..." cd /app || exit - exec s6-setuidgid app /usr/local/bin/python3 -u /app/manage.py dsmr_datalogger + nice -n 5 s6-setuidgid app /usr/local/bin/python3 -u /app/manage.py dsmr_datalogger else sleep infinity -fi +fi \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/type b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/type index bdd22a1..5883cff 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/type +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/type @@ -1 +1 @@ -oneshot +longrun diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-remote-datalogger/dependencies b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-remote-datalogger/dependencies old mode 100644 new mode 100755 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-remote-datalogger/run b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-remote-datalogger/run index fa6a9fb..5f778b6 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-remote-datalogger/run +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-remote-datalogger/run @@ -4,7 +4,7 @@ if [[ "${DSMRREADER_OPERATION_MODE}" = api_client ]]; then echo "Starting DSMR Reader - remote datalogger (api_client)..." cd /app || exit - exec s6-setuidgid app /usr/local/bin/python3 -u /app/dsmr_datalogger_api_client.py + nice -n 5 s6-setuidgid app /usr/local/bin/python3 -u /app/dsmr_datalogger_api_client.py else sleep infinity -fi +fi \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/dependencies b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/dependencies new file mode 100755 index 0000000..aa61ec9 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/dependencies @@ -0,0 +1 @@ +svc-dsmr-webinterface \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/run b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/run new file mode 100755 index 0000000..3c9681d --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/run @@ -0,0 +1,4 @@ +#!/command/with-contenv bash +# shellcheck shell=bash + +s6-log -bp -- /var/log/dsmr_webinterface \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/type b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/type new file mode 100755 index 0000000..5883cff --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/type @@ -0,0 +1 @@ +longrun diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/up b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/up new file mode 100755 index 0000000..d56fc07 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/run diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/dependencies b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/dependencies old mode 100644 new mode 100755 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/run b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/run index 1ff78bb..cb9096b 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/run +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/run @@ -4,7 +4,7 @@ if [[ "${DSMRREADER_OPERATION_MODE}" = standalone || "${DSMRREADER_OPERATION_MODE}" = api_server ]]; then echo "Starting DSMR Reader - webinterface..." cd /app || exit - exec s6-setuidgid app /usr/local/bin/gunicorn dsmrreader.wsgi --timeout 60 --max-requests 500 --bind unix:/tmp/gunicorn--dsmr_webinterface.socket + nice -n 15 s6-setuidgid app /usr/local/bin/gunicorn dsmrreader.wsgi --timeout 60 --max-requests 500 --bind unix:/tmp/gunicorn--dsmr_webinterface.socket else sleep infinity fi diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/type b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/type index 5883cff..1780f9f 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/type +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/type @@ -1 +1 @@ -longrun +longrun \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/dependencies b/rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/dependencies old mode 100644 new mode 100755 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/run b/rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/run index 9d7d69d..0569c6d 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/run +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/run @@ -4,7 +4,8 @@ if [[ "${DSMRREADER_OPERATION_MODE}" = standalone || "${DSMRREADER_OPERATION_MODE}" = api_server ]]; then echo "Starting DSMR Reader - nginx..." cd /app || exit - exec /usr/sbin/nginx -g "daemon off;" + # s6-setuidgid app + /usr/sbin/nginx -g 'daemon off;' else sleep infinity fi diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-dsmr-backend-log b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-dsmr-backend-log new file mode 100755 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-dsmr-datalogger-log b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-dsmr-datalogger-log new file mode 100755 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-dsmr-webinterface-log b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-dsmr-webinterface-log new file mode 100755 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-nginx b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-nginx old mode 100644 new mode 100755