feat(host): daemon mode, structured logging, instance management#6
Merged
feat(host): daemon mode, structured logging, instance management#6
Conversation
Major refactor of jaunt-host for production-ready operation: - **Structured logging**: Replace all eprintln! with tracing macros at appropriate levels (info/warn/error/debug/trace). File logging for daemon mode, stderr for foreground. - **DHT noise filtering**: Track known jaunt clients (peers that sent RPC or completed pairing). Log client connections at INFO, DHT routing peers at TRACE. Dial errors at DEBUG. - **Instance management**: PID file at $XDG_RUNTIME_DIR/jaunt-host.pid. Prevents multiple instances. `jaunt-host stop` sends SIGTERM. `jaunt-host status` checks if daemon is running. - **Graceful shutdown**: Handle SIGTERM/SIGINT in the event loop via tokio::select!. Clean up PID file on exit. - **Daemon mode**: `jaunt-host serve -d` forks to background via nix::unistd::daemon(). Logs to ~/.local/share/jaunt/jaunt-host.log. - **Serve/pair separation**: `serve` no longer generates PINs or starts the pairing HTTP server — it only accepts paired devices. `pair` is the interactive command for adding new devices. - **systemd service file**: packaging/systemd/jaunt-host.service
574fc21 to
f800994
Compare
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.
Summary
Major refactor of jaunt-host for production-ready operation. Addresses all 5 problems from the daemon UX investigation.
New features
jaunt-host serve -d— daemon mode (forks to background, logs to~/.local/share/jaunt/jaunt-host.log)jaunt-host stop— cleanly stop a running daemon (SIGTERM → 5s wait → SIGKILL)jaunt-host status— check if daemon is runningjaunt-host pair— interactive pairing (generates PIN, starts HTTP server, waits for device, exits)$XDG_RUNTIME_DIR/jaunt-host.pid)packaging/systemd/jaunt-host.serviceBehavioral changes
serveno longer generates PINs or starts the pairing HTTP server. Usepairto add devices first.eprintln!replaced withtracingmacros (info!/warn!/debug!/trace!). Configurable viaRUST_LOGenv var.Workflow
Test plan
cargo fmt --checkpassescargo clippy --workspace --all-targets -- -D warningspassescargo test --workspace— 25 tests passjaunt-host --helpshows all 5 subcommandsjaunt-host status/jaunt-host stopwork correctly