fix(daemon): rotate dashboard.log on start instead of truncating#204
Draft
esphbot wants to merge 1 commit into
Draft
fix(daemon): rotate dashboard.log on start instead of truncating#204esphbot wants to merge 1 commit into
esphbot wants to merge 1 commit into
Conversation
dashboard.log was opened with File::create on every backend start, which truncates it — so each app launch or backend restart wiped the previous run's logs. After a failed self-update restart (issue esphome#203) there was nothing left to inspect, exactly when the logs matter most. Rotate the prior dashboard.log to numbered backups (dashboard.log.1..3) before creating a fresh one. Best-effort: a rotation failure logs a warning and start proceeds, since losing old logs must never block the backend. The tray "View Logs" entry opens this folder, so the retained runs are directly browsable.
Contributor
📦 Build ArtifactsThe following artifacts are available from this build: WindowsLinux
macOSNote These macOS builds are not signed or notarized, so Gatekeeper will refuse to open them. To run one, download the dmg, then re-sign it locally with the helper script from this repo. It needs no Apple certificate; by default it applies an ad-hoc signature that lets the app open on your own machine. No local clone required — download the script and run it directly: curl -fsSL https://raw.githubusercontent.com/esphome/esphome-desktop/main/build-scripts/sign_macos_local.sh -o sign_macos_local.sh
bash sign_macos_local.sh ~/Downloads/the-downloaded.dmgMount the resulting Last updated: 2b04e4c - Run #545 - 2026-06-22 05:10:56 UTC |
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.
What
Rotate
dashboard.logon backend start instead of truncating it, keeping the last 3 runs (dashboard.log.1...3).Why
dashboard.logwas opened withFile::createon every backend start (daemon/mod.rs), which truncates. Each app launch or backend restart wiped the previous run's logs. Issue #203 reports a macOS self-update restart where the dashboard comes back unreachable as a remote build server — and the only available log is "truncated on every startup," so there's nothing to inspect at the exact moment it's needed.How
util::rotate_log(path, keep)— best-effort, dependency-free numbered rotation (path→path.1→ … →path.{keep}, oldest discarded). No-op on first run /keep == 0.daemon::start()rotates beforeFile::create; a rotation failure logs a warning and start proceeds (losing old logs must never block the backend). The tray "View Logs" entry opens this folder, so retained runs are browsable.Scope: this addresses the log-truncation half of #203. The primary "restart comes back unreachable" symptom is the backend's mDNS/port release timing on relaunch — the same class redirected upstream as device-builder#1642; I deliberately did not add a launcher-side process gate for it (see PR #202's outcome). Rotated logs are precisely what's needed to confirm that diagnosis from a user's machine.
App-level (tracing) file logging — the other thing #203 asks for — is a larger change (the subscriber inits before the data dir is resolved) and is left as a follow-up.
Testing
rotate_log(first-run no-op, single shift, multi-run history ordering + oldest discarded,keep == 0).cargo test/clippy/cross-platform build.Quality Report
Changes: 2 files changed, 119 insertions(+), 2 deletions(-)
Code scan: clean
Tests: passed (67 passed)
Branch hygiene: clean
Generated by Kōan