From 314590d97f51d76086af9be3741ac44dc0680ed7 Mon Sep 17 00:00:00 2001 From: buanet Date: Tue, 23 Jun 2020 00:23:42 +0200 Subject: [PATCH] some testing --- amd64/scripts/iobroker_startup.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 9916a81..0d0fb0d 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -439,9 +439,6 @@ then fi -sleep 5 - - ##### # Starting ioBroker ##### @@ -452,7 +449,19 @@ echo ' ' echo "Starting ioBroker..." echo ' ' -exec gosu iobroker node node_modules/iobroker.js-controller/controller.js +# Function for graceful shutdown by SIGTERM signal +shut_down() { + echo ' ' + echo "Recived termination signal (SIGTERM)." + echo "Shutting down ioBroker..." + pid=$(ps -ef | awk '/[j]s.controller/{print $2}') + kill -SIGTERM "$pid" + exit +} + +trap 'shut_down' SIGTERM + +gosu iobroker node node_modules/iobroker.js-controller/controller.js & wait # Preventing container restart by keeping a process alive even if iobroker will be stopped tail -f /dev/null