feat(updater): auto-update binary from Forgejo releases at 2am daily #19
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "exe-dev-bot/kiosk:feat/auto-update"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The kiosk web server now auto-updates itself at 2am daily by checking Forgejo releases.
How it works
StartAutoUpdater()launches a goroutine that sleeps until the next 2:00 AM local time, then runs the update check every 24 hourshttps://git.kwila.cloud/api/v1/repos/kwila/kiosk/releases?limit=1and compares the releasetag_nameagainst the build-timeversionvariableruntime.GOARCH(e.g.kiosk-arm64), downloads to a temp file in the same directorychmod +x, then atomicos.Renameover the running binaryos.Exit(0). Since the systemd service hasRestart=always, it comes back up running the new versionAll errors are logged, never fatal — retries next day.
Build-time version injection
The
justfilenow injects version via ldflags:Defaults to
devfor local builds. CI should pass the release tag.Changes
updater.go— Core auto-update logic (scheduler, API check, download, replace, exit)updater_test.go— 8 tests with httptest mock server covering all pathsmain.go— Wire inStartAutoUpdater()calljustfile— Addversionvariable, inject via-ldflagsin build recipe, expand test recipe to./...Tests