From 0b0efb96ccbd17c67938fcdb57f97ac9153e3cce Mon Sep 17 00:00:00 2001 From: Felipe Lalanne <1822826+pipex@users.noreply.github.com> Date: Mon, 4 Sep 2023 13:59:44 -0300 Subject: [PATCH 1/2] Update wait-for-it script to fail if interrupted This fixes a potential race condition where the github runners may stop the `sut` service before the wait timer is reached, resulting in a 0 exit code returned by the service, leading to a false negative test. Change-type: patch --- test/lib/wait-for-it.sh | 8 ++++++++ 1 file changed, 8 insertions(+) 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 From 3373ec0e7c57d5eb759c8e844e3a227fba9b4ebb Mon Sep 17 00:00:00 2001 From: Christina Ying Wang Date: Thu, 14 Sep 2023 15:40:01 -0700 Subject: [PATCH 2/2] Send SIGUSR2 signal to Node to snapshot Signed-off-by: Christina Ying Wang --- Dockerfile.template | 2 ++ entry.sh | 2 +- profile.sh | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 profile.sh 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