Skip to content

Commit

Permalink
add auto-retry on steamcmd errors
Browse files Browse the repository at this point in the history
  • Loading branch information
patrix87 committed Jun 26, 2023
1 parent d7d520b commit 1ca32de
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 16 additions & 1 deletion functions/server/Update-Server.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,22 @@ function Update-Server {
#Run the update String
Write-ServerMsg "$UpdateType $ValidatingString $VersionString Build."
try {
$Task = Start-Process $Global.SteamCMD -ArgumentList "+runscript `"$ScriptPath`"" -Wait -PassThru -NoNewWindow
$ExitCode = -1
$Retries = 0
while ($ExitCode -ne 0 -and $Retries -lt $Global.MaxDownloadRetries) {
$Task = Start-Process $Global.SteamCMD -ArgumentList "+runscript `"$ScriptPath`"" -Wait -PassThru -NoNewWindow
$ExitCode = $Task.ExitCode
if ($ExitCode -ne 0) {
Write-ServerMsg "SteamCMD failed to complete. Retrying..."
$Retries++
}
else {
Write-ServerMsg "SteamCMD completed successfully."
}
}
if ($Retries -eq $Global.MaxDownloadRetries) {
Exit-WithError -ErrorMsg "SteamCMD failed to complete after $Global.MaxDownloadRetries retries."
}
}
catch {
Exit-WithError -ErrorMsg "SteamCMD failed to complete."
Expand Down
3 changes: 3 additions & 0 deletions global.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ $GlobalDetails = @{

#Lock Timeout in miuntes
LockTimeout = 10

#Max download retries
MaxDownloadRetries = 5
}

#Create the object
Expand Down

0 comments on commit 1ca32de

Please sign in to comment.