Skip to content

Commit

Permalink
restructure logging, bugfix and fix datalogger service
Browse files Browse the repository at this point in the history
  • Loading branch information
Bram van Dartel committed Apr 18, 2024
1 parent f3e0476 commit 7c8a90e
Show file tree
Hide file tree
Showing 31 changed files with 78 additions and 17 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
10 changes: 10 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/sig-handler/run
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/sig-handler/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/sig-handler/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/sig-handler/run
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
svc-dsmr-backend
5 changes: 5 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/run
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/svc-dsmr-backend-log/run
Empty file modified rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend/dependencies
100644 → 100755
Empty file.
11 changes: 8 additions & 3 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend/run
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
svc-dsmr-datalogger
5 changes: 5 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/run
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger-log/run
Empty file modified rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/dependencies
100644 → 100755
Empty file.
11 changes: 8 additions & 3 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/run
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/type
Original file line number Diff line number Diff line change
@@ -1 +1 @@
oneshot
longrun
Empty file.
11 changes: 8 additions & 3 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-remote-datalogger/run
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
svc-dsmr-datalogger
5 changes: 5 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/run
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface-log/run
Empty file.
9 changes: 7 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/run
Original file line number Diff line number Diff line change
@@ -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
Empty file modified rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/dependencies
100644 → 100755
Empty file.
8 changes: 6 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/run
Original file line number Diff line number Diff line change
@@ -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
Empty file.
Empty file.
Empty file.
Empty file modified rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/svc-nginx
100644 → 100755
Empty file.

0 comments on commit 7c8a90e

Please sign in to comment.