-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add session-task script for video recording
- Loading branch information
Showing
4 changed files
with
70 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
max_recorded_count=$((${DRAIN_AFTER_SESSION_COUNT:-SE_DRAIN_AFTER_SESSION_COUNT})) | ||
recorded_count=0 | ||
last_session_id="" | ||
|
||
function get_session_id { | ||
session_id=$(curl -s --request GET 'http://'${DISPLAY_CONTAINER_NAME}':'${SE_NODE_PORT}'/status' | jq -r '.[]?.node?.slots | .[0]?.session?.sessionId') | ||
} | ||
|
||
function capture_session() { | ||
echo "${POD_NAME}" > ${SE_SESSION_FOLDER}'/'$session_id'.txt' | ||
cat ${SE_SESSION_FOLDER}'/'$session_id'.txt' | ||
last_session_id=$session_id | ||
recorded_count=$((recorded_count+1)) | ||
} | ||
|
||
function terminate_gracefully { | ||
echo "Trapped SIGTERM/SIGINT/x so shutting down the listener..." | ||
while true; | ||
do | ||
get_session_id | ||
if [ "$session_id" != "null" -a "$session_id" != "" ]; | ||
then | ||
echo "Session: $session_id is active, waiting for it to finish" | ||
sleep 2 | ||
else | ||
break | ||
fi | ||
done | ||
echo "Shutdown completed!" | ||
exit 0 | ||
} | ||
|
||
trap terminate_gracefully SIGTERM SIGINT | ||
|
||
while true; | ||
do | ||
get_session_id | ||
if [ "$session_id" != "null" -a "$session_id" != "" ] && [ "$last_session_id" != "$session_id" ]; | ||
then | ||
capture_session | ||
else | ||
sleep 2 | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters