[Arma 3] Added RPT logging (#253)

- Adds RPT logging (logs will be located in `/home/container/serverprofile/rpt/`, but only if `-noLogs` is not used as a startup parameter)
- Fixes edge case where clearing HC cache on first boot may fail due to a missing `serverprofile/` folder.
This commit is contained in:
Matthew Dangerfield
2024-07-07 19:24:02 -04:00
committed by GitHub
parent efc8507ae1
commit 681ffc488d

View File

@@ -346,6 +346,12 @@ if [[ ${MODS_LOWERCASE} == "1" ]]; then
done
fi
# Define the log file path with a timestamp
LOG_FILE="/home/container/serverprofile/rpt/arma3server_$(date '+%m_%d_%Y_%H%M%S').rpt"
# Ensure the logs directory exists
mkdir -p /home/container/serverprofile/rpt
# Clear HC cache, if specified
if [[ ${CLEAR_CACHE} == "1" ]]; then
echo -e "\n${GREEN}[STARTUP]: ${CYAN}Clearing Headless Client profiles cache...${NC}"
@@ -395,7 +401,11 @@ fi
# Start the Server
echo -e "\n${GREEN}[STARTUP]:${NC} Starting server with the following startup command:"
echo -e "${CYAN}${modifiedStartup}${NC}\n"
${modifiedStartup}
if [[ "$STARTUP_PARAMS" == *"-noLogs"* ]]; then
${modifiedStartup}
else
${modifiedStartup} 2>&1 | tee -a "$LOG_FILE"
fi
if [ $? -ne 0 ]; then
echo -e "\n${RED}PTDL_CONTAINER_ERR: There was an error while attempting to run the start command.${NC}\n"