Skip to content

Commit

Permalink
Development (#360)
Browse files Browse the repository at this point in the history
* restructured logging to stdout
* update datalogger bug (oneshot instead of longrun)

---------

Co-authored-by: Bram van Dartel <[email protected]>
Co-authored-by: Bram van Dartel <[email protected]>
  • Loading branch information
3 people authored Apr 19, 2024
1 parent f3e0476 commit fb176cd
Show file tree
Hide file tree
Showing 31 changed files with 37 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
################################################
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
8 changes: 4 additions & 4 deletions rootfs/etc/s6-overlay/s6-rc.d/init-docker-entrypoint/run
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
svc-dsmr-backend
4 changes: 4 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,4 @@
#!/command/with-contenv bash
# 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.
4 changes: 2 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-backend/run
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
svc-dsmr-datalogger
4 changes: 4 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,4 @@
#!/command/with-contenv bash
# 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.
4 changes: 2 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-datalogger/run
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.
4 changes: 2 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-remote-datalogger/run
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
svc-dsmr-webinterface
4 changes: 4 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,4 @@
#!/command/with-contenv bash
# 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.
2 changes: 1 addition & 1 deletion rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/run
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion rootfs/etc/s6-overlay/s6-rc.d/svc-dsmr-webinterface/type
Original file line number Diff line number Diff line change
@@ -1 +1 @@
longrun
longrun
Empty file modified rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/dependencies
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion rootfs/etc/s6-overlay/s6-rc.d/svc-nginx/run
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 fb176cd

Please sign in to comment.