From a054d3b6890e63627f8194ac30040af1507dca49 Mon Sep 17 00:00:00 2001 From: Mariusz Marciniak Date: Wed, 17 Jan 2024 13:02:37 +0100 Subject: [PATCH] KASM-5378 Update vnc_startup.sh to wait until recorder service terminates in case of Xvnc being killed --- src/common/startup_scripts/vnc_startup.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/common/startup_scripts/vnc_startup.sh b/src/common/startup_scripts/vnc_startup.sh index f0b7281..8db804d 100755 --- a/src/common/startup_scripts/vnc_startup.sh +++ b/src/common/startup_scripts/vnc_startup.sh @@ -353,6 +353,19 @@ function ensure_recorder_running () { fi } +function ensure_recorder_terminates_gracefully () { + local kasm_recorder_process="/dockerstartup/recorder/kasm_recorder_service" + + while true + do + recorder_pid=$(pgrep -f "$kasm_recorder_process") || true + if [[ -z $recorder_pid ]]; then + break + fi + + sleep 1 + done +} ############ END FUNCTION DECLARATIONS ########### @@ -452,6 +465,14 @@ do ;; window_manager) echo "Window manager crashed, restarting" + + if [[ ${KASM_SVC_RECORDER:-1} == 1 ]]; then + echo "Waiting for recorder service to upload all pending recordings" + ensure_recorder_terminates_gracefully + echo "Recorder service has terminated, exiting container" + exit 1 + fi + start_window_manager ;; kasm_audio_out_websocket)