Skip to content

feat(host): daemon mode, structured logging, instance management#6

Merged
moukrea merged 2 commits intomainfrom
feat/daemon-mode
Mar 29, 2026
Merged

feat(host): daemon mode, structured logging, instance management#6
moukrea merged 2 commits intomainfrom
feat/daemon-mode

Conversation

@moukrea
Copy link
Copy Markdown
Owner

@moukrea moukrea commented Mar 29, 2026

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 running
  • jaunt-host pair — interactive pairing (generates PIN, starts HTTP server, waits for device, exits)
  • PID file — prevents multiple instances ($XDG_RUNTIME_DIR/jaunt-host.pid)
  • Graceful shutdown — SIGTERM/SIGINT handled cleanly, PID file removed
  • systemd service filepackaging/systemd/jaunt-host.service

Behavioral changes

  • serve no longer generates PINs or starts the pairing HTTP server. Use pair to add devices first.
  • DHT peer noise eliminated — only actual jaunt clients are logged at INFO level. DHT routing peers → TRACE. Dial errors → DEBUG.
  • Structured logging — all eprintln! replaced with tracing macros (info!/warn!/debug!/trace!). Configurable via RUST_LOG env var.

Workflow

jaunt-host pair          # Add a new device (interactive)
jaunt-host serve         # Run in foreground
jaunt-host serve -d      # Run as daemon
jaunt-host status        # Check if running
jaunt-host stop          # Stop daemon

Test plan

  • cargo fmt --check passes
  • cargo clippy --workspace --all-targets -- -D warnings passes
  • cargo test --workspace — 25 tests pass
  • jaunt-host --help shows all 5 subcommands
  • jaunt-host status / jaunt-host stop work correctly

moukrea added 2 commits March 29, 2026 22:14
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
@moukrea moukrea merged commit 77a2bd0 into main Mar 29, 2026
4 checks passed
@moukrea moukrea deleted the feat/daemon-mode branch March 29, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant