Skip to content
Snippets Groups Projects
Commit 36e5015c authored by Simon McVittie's avatar Simon McVittie
Browse files

Merge branch 'wip/restart-container' into 'master'

Optionally shut down and relaunch container

See merge request !23
parents 0f9c98f8 231f4c2c
No related branches found
No related tags found
1 merge request!23Optionally shut down and relaunch container
Pipeline #5653 passed with warnings
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
/depot/steam-runtime/ /depot/steam-runtime/
/depot/toolmanifest.vdf /depot/toolmanifest.vdf
/depot/toolmanifest.v2.vdf /depot/toolmanifest.v2.vdf
/depot/var/
/local/ /local/
/pressure-vessel-*-bin+src.tar.gz /pressure-vessel-*-bin+src.tar.gz
/pressure-vessel-*-bin.tar.gz /pressure-vessel-*-bin.tar.gz
......
...@@ -142,7 +142,8 @@ verbose "Starting pressure-vessel-launcher in background" ...@@ -142,7 +142,8 @@ verbose "Starting pressure-vessel-launcher in background"
--info-fd=3 \ --info-fd=3 \
--socket-directory="$rendezvous" \ --socket-directory="$rendezvous" \
< /dev/null >&2 3>"$rendezvous/fifo" & < /dev/null >&2 3>"$rendezvous/fifo" &
verbose "Started pressure-vessel-launcher in background" container_pid="$!"
verbose "Started pressure-vessel-launcher in background, pid $container_pid"
socket=$( socket=$(
while read -r line; do while read -r line; do
case "$line" in case "$line" in
...@@ -153,6 +154,16 @@ socket=$( ...@@ -153,6 +154,16 @@ socket=$(
esac esac
done < "$rendezvous/fifo" done < "$rendezvous/fifo"
) )
if [ -z "$socket" ] || ! [ -S "$socket" ]; then
log "Error starting pressure-vessel container"
if [ -z "${PRESSURE_VESSEL_VERBOSE-}" ]; then
log "Try environment variable PRESSURE_VESSEL_VERBOSE=1 for more details"
fi
kill "$container_pid" || :
exit 70 # EX_SOFTWARE
fi
ln -fns "$socket" "$rendezvous/socket" ln -fns "$socket" "$rendezvous/socket"
verbose "OK, ready to exit" verbose "OK, ready to exit"
exit 0 exit 0
......
...@@ -137,9 +137,25 @@ log "STEAM_COMPAT_SESSION_ID=${STEAM_COMPAT_SESSION_ID-}" ...@@ -137,9 +137,25 @@ log "STEAM_COMPAT_SESSION_ID=${STEAM_COMPAT_SESSION_ID-}"
# done securely. # done securely.
log "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR-}" log "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR-}"
# In non-session mode, we always behave like the main program relaunch=
if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then
verbose "Non-session mode, behaving like the main program"
is_main=yes is_main=yes
elif [ -n "$is_main" ]; then
verbose "Main program in session mode"
case "${PRESSURE_VESSEL_RELAUNCH_CONTAINER-0}" in
(1)
relaunch=yes
;;
(0)
;;
(*)
echo "\$PRESSURE_VESSEL_RELAUNCH_CONTAINER should be either 0 or 1" >&2
;;
esac
else
verbose "Setup program in session mode"
fi fi
# At this point $LD_LIBRARY_PATH might # At this point $LD_LIBRARY_PATH might
...@@ -193,7 +209,7 @@ pressure_vessel="${PRESSURE_VESSEL_PREFIX:-"${here}/pressure-vessel"}" ...@@ -193,7 +209,7 @@ pressure_vessel="${PRESSURE_VESSEL_PREFIX:-"${here}/pressure-vessel"}"
# Arguments for pressure-vessel-wrap, currently none # Arguments for pressure-vessel-wrap, currently none
declare -a container_args=() declare -a container_args=()
if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then exec_container () {
# Run as a single command # Run as a single command
exec "$here/run-in-steamrt" \ exec "$here/run-in-steamrt" \
--arch=amd64,i386 \ --arch=amd64,i386 \
...@@ -207,10 +223,16 @@ if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then ...@@ -207,10 +223,16 @@ if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then
"$@" \ "$@" \
${NULL+} ${NULL+}
exit 125 exit 125
}
if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then
verbose "Non-session mode, just running the container"
exec_container "$@"
# not reached # not reached
fi fi
# Session mode. Either PRESSURE_VESSEL_SOCKET_DIR or XDG_RUNTIME_DIR are required. # Session mode. Either PRESSURE_VESSEL_SOCKET_DIR or XDG_RUNTIME_DIR are required.
verbose "Session mode"
if [[ -v PRESSURE_VESSEL_SOCKET_DIR ]]; then if [[ -v PRESSURE_VESSEL_SOCKET_DIR ]]; then
if ! [ -O "$PRESSURE_VESSEL_SOCKET_DIR" ]; then if ! [ -O "$PRESSURE_VESSEL_SOCKET_DIR" ]; then
...@@ -247,10 +269,22 @@ terminate_container () { ...@@ -247,10 +269,22 @@ terminate_container () {
--terminate --terminate
} }
if [ -n "$is_main" ] && [ -n "$rendezvous" ]; then if [ -n "$relaunch" ]; then
verbose "Terminating and re-launching container for main game"
terminate_container || :
exec_container "$@"
# not reached
fi
if [ -n "$is_main" ]; then
trap terminate_container EXIT trap terminate_container EXIT
fi fi
# Launch the pressure-vessel-launcher(1). This is used to run the
# setup commands (--verb=run), if any. If not requested via
# PRESSURE_VESSEL_RELAUNCH_CONTAINER=1, it is also used to run the
# actual game.
#
# We have to launch pressure-vessel-launcher(1) *without* setting # We have to launch pressure-vessel-launcher(1) *without* setting
# SteamAppId, SteamAppUser, etc., otherwise Steam will think the game # SteamAppId, SteamAppUser, etc., otherwise Steam will think the game
# is already running and refuse to run it again. (Tested with SteamAppId, # is already running and refuse to run it again. (Tested with SteamAppId,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment