diff --git a/Dockerfile b/Dockerfile index 6cbba73..d25a34b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,9 +33,10 @@ ENV PS1="$(whoami)@dsmr_reader_docker:$(pwd)\\$ " \ 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 + PIP_NO_CACHE_DIR=1 + # S6_SERVICES_GRACETIME=30000 \ + # S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 + # S6_BEHAVIOUR_IF_STAGE2_FAILS=1 ENV DJANGO_SECRET_KEY=dsmrreader \ DJANGO_DATABASE_ENGINE=django.db.backends.postgresql \ diff --git a/rootfs/etc/s6-overlay/s6-rc.d/sig-handler/run b/rootfs/etc/s6-overlay/s6-rc.d/sig-handler/run new file mode 100755 index 0000000..1e42a57 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/sig-handler/run @@ -0,0 +1,10 @@ +#!/bin/execlineb -P +# /etc/s6-overlay/s6-rc.d/sig-handler/run +# shellcheck shell=bash + +# Trap SIGINT and gracefully shutdown +foreground { + s6-trap-init SIGINT +} +importas -u SIGINT SIGINT +s6-svscanctl -t /var/run/s6/services diff --git a/rootfs/etc/s6-overlay/s6-rc.d/sig-handler/type b/rootfs/etc/s6-overlay/s6-rc.d/sig-handler/type new file mode 100755 index 0000000..1780f9f --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/sig-handler/type @@ -0,0 +1 @@ +longrun \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/sig-handler/up b/rootfs/etc/s6-overlay/s6-rc.d/sig-handler/up new file mode 100755 index 0000000..18cbcab --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/sig-handler/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/sig-handler/run \ No newline at end of file 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..6cda5e2 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/run @@ -0,0 +1,5 @@ +#!/bin/execlineb -P +# /etc/s6-overlay/s6-rc.d/dsmr_backend-log/run +# 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..ddd82a3 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 @@ -1,10 +1,15 @@ -#!/command/with-contenv bash +#!/bin/execlineb -P +# /etc/s6-overlay/s6-rc.d/dsmr_backend/run # shellcheck shell=bash +with-contenv + 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 /dsmr/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..1f5af81 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/run @@ -0,0 +1,5 @@ +#!/bin/execlineb -P +# /etc/s6-overlay/s6-rc.d/dsmr_datalogger-log/run +# 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..dcb4a9b 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 @@ -1,10 +1,15 @@ -#!/command/with-contenv bash +#!/bin/execlineb -P +# /etc/s6-overlay/s6-rc.d/dsmr_datalogger/run # shellcheck shell=bash +with-contenv + 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 /dsmr/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..a605ecd 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 @@ -1,10 +1,15 @@ -#!/command/with-contenv bash +#!/bin/execlineb -P +# /etc/s6-overlay/s6-rc.d/dsmr_client_datalogger/run # shellcheck shell=bash +with-contenv + 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 /dsmr/dsmr_datalogger/scripts/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..13cf561 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-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-webinterface-log/run b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/run new file mode 100755 index 0000000..a5ca6e7 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/run @@ -0,0 +1,5 @@ +#!/bin/execlineb -P +# /etc/s6-overlay/s6-rc.d/dsmr_webinterface-log/run +# 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..97cdf70 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 @@ -1,10 +1,15 @@ -#!/command/with-contenv bash +#!/bin/execlineb -P +# /etc/s6-overlay/s6-rc.d/dsmr_webinterface/run # shellcheck shell=bash +with-contenv + 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-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..e023f3d 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/run +++ b/rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/run @@ -1,10 +1,14 @@ -#!/command/with-contenv bash +#!/bin/execlineb -P +# /etc/s6-overlay/s6-rc.d/nginx/run # shellcheck shell=bash +with-contenv + 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