Repository navigation
Conversation
A second update, force-update, validate or workshop-update started while another was running (for example the docker entrypoint update and the cron update) ran SteamCMD into the same serverfiles at the same time and broke both downloads. The new check_update_lock.sh writes the PID to lock/updating.lock with noclobber, and a second run prints "Update is already running" and exits 0. A lock whose PID is dead, or was reused by a process started after the lock was written, is removed. core_exit.sh removes the lock when the owning command exits. fn_dl_steamcmd fixes: - A failing baseappid download ran continue, which skipped the error report and the retry limit, so it retried forever without a message. - The SteamCMD log was only cleared before the loop and every Error! in it was counted against the attempt counter. After an attempt with two different errors, a later successful attempt still reported "Update required but not completed" and SteamCMD ran again. The log is now cleared before every attempt.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Stops a second
update,force-update,validateorworkshop-updatefrom running SteamCMD while another one is already running, and fixes two bugs in the SteamCMD retry loop that made a failing base app retry forever.Update lock. The new
check_update_lock.shruns right aftercheck.sh/core_logs.shincommand_update.sh,command_validate.shandcommand_workshop_update.sh. It writes$$tolgsm/lock/updating.lockwithnoclobber, so two runs started at the same moment cannot both take the lock. If the lock is held, the second run printsChecking update: Update is already running (PID n)and exits 0, with no alert. Works the same way as<selfname>-warning.lock:ps -o etimes) is also treated as stale. In a container the PIDs repeat after a restart, so a lock left by a killed update could otherwise match an unrelated process and block updates for good.core_exit.shremoves the lock when the command that took it exits, including on CTRL-C. Nested calls (startwithupdateonstart,mods-removerunningvalidate, the stop/start insidefn_update_apply) see their own PID and do not release it early.The lock is not per-instance, like
update.lock, because instances in the same rootdir share serverfiles.update.lockand monitor'sfn_monitor_check_updateare unchanged.SteamCMD retry loop (
fn_dl_steamcmd).baseappiddownload failed, the loop rancontinue, which skipped the error report and the 10 retry limit, so a failing base app retried forever with no message. This kept the tf2cserver update running for an hour. The main app now only downloads when the base app succeeded, and the error check and retry limit run for every attempt.${selfname}-steamcmd.logwas only cleared before the loop, and the check counted everyError!in the accumulated log against the attempt counter. After an attempt that printed two different errors, a later successful attempt still reported "Update required but not completed - check network". That error also sets a non-zero exit code, so SteamCMD ran again after a download that had already worked. The log is now cleared before every attempt, and each attempt is checked against its own output only.Fixes #5094
Affected servers: all SteamCMD servers
Type of change
Testing
gameservermanagers/gameserver:vhcontainer (Valheim, anonymous SteamCMD, 2.2 GB), with--no-healthcheck,UPDATE_CHECK=0and no published ports. The develop and branchlgsm/moduleswere copied in in turn. Serverfiles were wiped, aforce-updatewas started in the background, and a second command was run 10 s into the SteamCMD download. SteamCMD processes were listed 15 s into the second command.Concurrency, develop: the second
force-updatestarts its own SteamCMD into the same serverfiles:Concurrency, branch:
update,force-updateandvalidateeach exit 0 without starting SteamCMD (only the first run's SteamCMD is listed):workshop-updategets the same check, but it was not tested here because Valheim has no Workshop support.The first run then finished (
Success! App '896660' fully installed.) andupdating.lockwas gone. A normalupdateafterwards ran as usual ("No update available", exit 0) and removed its lock.Stale locks, branch:
999999WARN: Checking update: Removing stale lockfile ...sleepstarted after the lock was written (lock mtime 10 minutes old)sleepstarted before the lock was writtenUpdate is already running (PID 20438), exit 0Retry loop: a stub
steamcmdearlier inPATHfailed chosen calls withERROR! Timed out waiting for AppInfo update.andError! App '<id>' state is 0x602 after update job., and passed the rest to the real SteamCMD.Success!, SteamCMD runs 3 timesbaseappid="1007"always failsDid not complete the download, too many retrysafter 11 attempts, exit 1shellcheck -xandshfmt -d -srare clean on every changed file, and all modules stay 100755.gameservermanagers/gameserver:vh(Ubuntu 24.04 base), Docker 29.4 on Ubuntu 26.04.Risk and rollback
lgsm/lock/updating.lockclears it.Breaking changes
Documentation
Checklist
PR will not be merged until all steps are complete.
Thank you for your Pull Request!