Skip to content

Commit

Permalink
Send SIGUSR2 signal to Node to snapshot
Browse files Browse the repository at this point in the history
Signed-off-by: Christina Ying Wang <christina@balena.io>
  • Loading branch information
cywang117 committed Sep 14, 2023
1 parent 0b0efb9 commit 3373ec0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions profile.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3373ec0

Please sign in to comment.