From e5a4331233689a71384f1e9a09ae42007b9d8788 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:48:58 +0100 Subject: [PATCH] Re-add trap --- postgres/rootfs/etc/cont-init.d/99-run.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index 80d923980..960eef070 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -34,6 +34,14 @@ cd /config || true bashio::log.info "Starting the app" +function shutdown_postgres { + echo "Received SIGTERM/SIGINT, shutting down PostgreSQL..." + gosu postgres pg_ctl -D "$PGDATA" -m fast stop + exit 0 +} + +trap 'shutdown_postgres' SIGTERM SIGINT + # Start background tasks if [ "$(bashio::info.arch)" != "armv7" ]; then /./docker-entrypoint-initdb.d/10-vector.sh & VECTOR_PID=$! @@ -43,6 +51,3 @@ else bashio::log.warning "ARMv7 detected: Starting without vectors.so" docker-entrypoint.sh postgres & POSTGRES_PID=$! fi - -# Wait for processes to finish -# wait "$VECTOR_PID" "$POSTGRES_PID"