diff --git a/Dockerfile.template b/Dockerfile.template index 3bf84fe48..a82d0ff15 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -86,6 +86,8 @@ COPY --from=journal /sysroot / # Copy mount script for mounting host partitions into container COPY mount-partitions.sh . +COPY profile.sh . + # Runtime dependencies RUN apk add --update --no-cache \ $NODE \ diff --git a/entry.sh b/entry.sh index ee1459fd9..b9a09f165 100755 --- a/entry.sh +++ b/entry.sh @@ -75,5 +75,5 @@ if [ "${LIVEPUSH}" = "1" ]; then exec npx nodemon --watch src --watch typings --ignore tests -e js,ts,json \ --exec node -r ts-node/register/transpile-only src/app.ts else - exec node /usr/src/app/dist/app.js + exec node --heapsnapshot-signal=SIGUSR2 /usr/src/app/dist/app.js fi diff --git a/profile.sh b/profile.sh new file mode 100755 index 000000000..2f13778fc --- /dev/null +++ b/profile.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +set -o errexit + +SUPERVISOR_PID=1 +# Snapshot interval in seconds (default: 3600s = 1h) +INTERVAL="${INTERVAL:-3600}" + +# Send a SIGUSR2 signal to the supervisor process once every INTERVAL +while true; do + kill -USR2 "${SUPERVISOR_PID}" + sleep "${INTERVAL}" +done \ No newline at end of file diff --git a/test/lib/wait-for-it.sh b/test/lib/wait-for-it.sh index 74f79f080..96d2a0181 100755 --- a/test/lib/wait-for-it.sh +++ b/test/lib/wait-for-it.sh @@ -79,11 +79,19 @@ abort_if_not_ready() { exit 1 } +abort_if_stopped() { + echo "Interrupted from external signal" >&2 + kill "$timer_pid" + exit 1 +} + # Trap the signal and start the timer if user timeout is greater than 0 if [ "$timeout" -gt 0 ]; then trap 'abort_if_not_ready' USR2 set_abort_timer "$timeout" $$ & timer_pid=$! + # Fail if a signal stops the script + trap 'abort_if_stopped' INT TERM fi # Wait for docker