Skip to content

Commit

Permalink
add UE 4.27 exit and crash handling
Browse files Browse the repository at this point in the history
  • Loading branch information
orcist authored Aug 27, 2024
1 parent 516adf0 commit 671967c
Showing 1 changed file with 53 additions and 1 deletion.
54 changes: 53 additions & 1 deletion src/UE4.27/Edgegap/StartServer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,57 @@
#!/bin/sh

# variable and function definitions
pid=$$
GAME_PORT=$(echo $ARBITRIUM_PORTS_MAPPING | jq '.ports.gameport.internal')

$(dirname "$0")/<PROJECT_NAME>Server.sh -log -PORT=$GAME_PORT
separator() {
printf "%0.s~" {1..80}
}

catch_kill() {
echo "SIGKILL signal received..."
separator()
kill -KILL "$pid" 2>/dev/null
}

catch_term() {
echo "SIGTERM signal received..."
separator()
kill -TERM "$pid" 2>/dev/null
}

catch_quit() {
echo "SIGTERM signal received..."
separator()
kill -QUIT "$pid" 2>/dev/null
}

# custom handling of process termination
trap catch_term SIGTERM
trap catch_kill SIGKILL
trap catch_quit SIGQUIT

# print variables for debugging purposes
separator()
echo ARBITRIUM_PORTS_MAPPING:
echo "$ARBITRIUM_PORTS_MAPPING"

separator()
echo ENVIRONMENT VARS:
env

# initialize game server
separator()
echo Execute command: $(dirname "$0")/<PROJECT_NAME>Server.sh -log -PORT=$GAME_PORT $UE_COMMANDLINE_ARGS
separator()
$(dirname "$0")/<PROJECT_NAME>Server.sh -log -PORT=$GAME_PORT $UE_COMMANDLINE_ARGS

# after game server process terminates
separator()
echo Gameserver exit code: $?

# if server terminated terminated from Unreal, stop deployment
separator()
echo Execute command: curl -sH "Authorization: ${ARBITRIUM_DELETE_TOKEN}" "${ARBITRIUM_DELETE_URL}" | jq -r '.'
curl -sH "Authorization: ${ARBITRIUM_DELETE_TOKEN}" "${ARBITRIUM_DELETE_URL}" | jq -r '.'
sleep infinity

0 comments on commit 671967c

Please sign in to comment.