mirror of
https://github.com/kasmtech/workspaces-core-images.git
synced 2024-11-25 00:43:11 +01:00
Merge branch 'feature/KASM-5378_recording_errata' into 'develop'
KASM-5378 Abort session if the recording service is not running or was not... Closes KASM-5378 See merge request kasm-technologies/internal/workspaces-core-images!156
This commit is contained in:
commit
a449b5b350
@ -1,31 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
action=$1
|
||||
|
||||
pid=$(pgrep -f '^/dockerstartup/recorder/kasm_recorder_service')
|
||||
|
||||
case $action in
|
||||
"stop"|"pause")
|
||||
if [ -z "$pid" ]; then
|
||||
echo "No recording process found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
kill -s SIGINT $pid
|
||||
while [ ! -f "/tmp/kasm_recorder.ack" ]; do
|
||||
sleep 1
|
||||
done
|
||||
;;
|
||||
"resume")
|
||||
if [ ! -z "$pid" ]; then
|
||||
echo "Recording process already running."
|
||||
exit 0
|
||||
fi
|
||||
kill `pgrep -f "kasm_recorder_startup.sh"`
|
||||
/dockerstartup/kasm_recorder_startup.sh &
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {stop|pause|resume}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
mkdir -p /opt/kasm/recordings
|
||||
chown kasm-recorder:kasm-recorder /opt/kasm/recordings
|
||||
chmod 700 /opt/kasm/recordings
|
||||
|
||||
# wait until X display is avaiable and allow the recorder to connect to it
|
||||
while ! xhost +SI:localuser:kasm-recorder 2>/dev/null; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
rm -rf /tmp/kasm_recorder.ack
|
||||
|
||||
while [ ! -f "/tmp/kasm_recorder.ack" ]; do
|
||||
runuser -m kasm-recorder -c "$STARTUPDIR/recorder/kasm_recorder_service --debug 1 --directory /opt/kasm/recordings/ --log /tmp/recorder.log" || true
|
||||
sleep 1
|
||||
done
|
@ -313,6 +313,60 @@ function custom_startup (){
|
||||
fi
|
||||
}
|
||||
|
||||
function ensure_recorder_running () {
|
||||
if [[ ${KASM_SVC_RECORDER:-1} != 1 ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local kasm_recorder_process="/dockerstartup/recorder/kasm_recorder_service"
|
||||
local kasm_recorder_ack="/tmp/kasm_recorder.ack"
|
||||
|
||||
if [[ -f "$kasm_recorder_ack" ]]; then
|
||||
local ack_user=$(stat -c '%U' $kasm_recorder_ack)
|
||||
if [[ "$ack_user" == "kasm-recorder" ]]; then
|
||||
SECONDS=0 #SECONDS is a built in bash variable that is incremented approximately every second
|
||||
kasm_recorder_pid=""
|
||||
fi
|
||||
fi
|
||||
|
||||
local recorder_pid=$(pgrep -f "^$kasm_recorder_process") || true
|
||||
|
||||
if [[ -z $kasm_recorder_pid ]]; then
|
||||
# This leverages the outside while loop that calls this function to provider checking ever x seconds.
|
||||
if [[ -z $recorder_pid ]] && (( $SECONDS > 15 )); then
|
||||
echo "$kasm_recorder_process: not started, exiting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
kasm_recorder_pid=$recorder_pid
|
||||
else
|
||||
if [[ -z $recorder_pid ]]; then
|
||||
echo "$kasm_recorder_process: not running, exiting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
recorder_user=$(ps -p $recorder_pid -o user=)
|
||||
if [[ $recorder_user != "kasm-recorder" ]]; then
|
||||
echo "$kasm_recorder_process: not running as kasm-recorder, exiting"
|
||||
exit 0
|
||||
fi
|
||||
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 ###########
|
||||
|
||||
if [[ $1 =~ -h|--help ]]; then
|
||||
@ -411,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)
|
||||
@ -457,6 +519,9 @@ do
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
||||
ensure_recorder_running
|
||||
|
||||
sleep 3
|
||||
done
|
||||
|
||||
|
@ -12,7 +12,7 @@ elif [ "${DISTRO}" == "opensuse" ]; then
|
||||
zypper install -ny xhost
|
||||
fi
|
||||
|
||||
COMMIT_ID="610a9d08d5e624d735b6d75814ef4d6770864076"
|
||||
COMMIT_ID="a871bde8bf4e209ab2a2b2022c3f0ab36f1319be"
|
||||
BRANCH="main"
|
||||
COMMIT_ID_SHORT=$(echo "${COMMIT_ID}" | cut -c1-6)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user