From c5afcde7c2204b37b1f9a04929eddb19ea86c03d Mon Sep 17 00:00:00 2001 From: Aaron van Meerten Date: Wed, 18 Sep 2024 13:06:24 -0500 Subject: [PATCH] feat(jigasi): support graceful shutdown via sidecar (#1908) --- jigasi/rootfs/etc/services.d/jigasi/finish | 9 +++++++++ jigasi/rootfs/opt/jitsi/shutdown.sh | 11 +++++++++++ 2 files changed, 20 insertions(+) create mode 100644 jigasi/rootfs/etc/services.d/jigasi/finish create mode 100755 jigasi/rootfs/opt/jitsi/shutdown.sh diff --git a/jigasi/rootfs/etc/services.d/jigasi/finish b/jigasi/rootfs/etc/services.d/jigasi/finish new file mode 100644 index 0000000..73ee50b --- /dev/null +++ b/jigasi/rootfs/etc/services.d/jigasi/finish @@ -0,0 +1,9 @@ +#!/usr/bin/with-contenv bash + +# When the jigasi is shutdown (or gracefully shutdown), it exits with code 0. +# In this case, we don't want S6 to restart the service. We want to stop all +# services and shutdown the container. + +if [[ $1 -eq 0 ]]; then + /opt/jitsi/shutdown.sh +fi diff --git a/jigasi/rootfs/opt/jitsi/shutdown.sh b/jigasi/rootfs/opt/jitsi/shutdown.sh new file mode 100755 index 0000000..4821f60 --- /dev/null +++ b/jigasi/rootfs/opt/jitsi/shutdown.sh @@ -0,0 +1,11 @@ +#!/usr/bin/with-contenv bash + +if [ -n "$AUTOSCALER_URL" ]; then + # notify the sidecar of imminent shutdown + PORT=${AUTOSCALER_SIDECAR_PORT:-6000} + curl -d '{}' -v 0:$PORT/hook/v1/shutdown + sleep 10 +fi + +# shutdown everything +s6-svscanctl -t /var/run/s6/services