Skip to content

Add og-veil restart command for seamless server restarts#13

Merged
adambalogh merged 1 commit into
mainfrom
claude/beautiful-curie-wu04i3
Jun 13, 2026
Merged

Add og-veil restart command for seamless server restarts#13
adambalogh merged 1 commit into
mainfrom
claude/beautiful-curie-wu04i3

Conversation

@adambalogh

Copy link
Copy Markdown
Contributor

Summary

Adds a new og-veil restart command that stops and restarts the background server without requiring re-authentication. This is particularly useful after running og-veil update to load the new version.

Key Changes

  • New restart command in veil/cli.py: Stops the running background server, waits for it to fully exit, then starts a fresh instance with the same or updated configuration. Accepts the same options as serve (host, port, tee-id, expected-pcr, pii-scrub).
  • New wait_until_stopped() function in veil/daemon.py: Polls a process ID to verify it has exited before proceeding, with configurable timeout and polling interval. Prevents port collision between old and new server instances.
  • Helper _pid_alive() function in veil/daemon.py: Uses os.kill(pid, 0) to check if a process is still running without sending a signal.
  • Updated documentation: Modified docstrings, CLI help text, README, and update command output to reference the new restart command instead of manual stop && serve workflow.
  • Comprehensive test coverage: Added three test cases for restart (normal restart, fresh start when nothing running, error handling when old process lingers) and two for wait_until_stopped() (timeout and successful wait scenarios).

Implementation Details

  • The restart command reuses the login session (no re-authentication needed) and respects environment-based configuration by default
  • Configuration flags can override environment variables if provided
  • The command fails gracefully if the old server process doesn't exit within the timeout, preventing the new server from starting while the old one still occupies the port
  • Process polling uses a 5-second default timeout with 0.1-second intervals for responsive but not CPU-intensive checking

https://claude.ai/code/session_01TYNjSYZ6QoreCr2dcURYSH

Adds a `restart` subcommand that stops the background server (if running),
waits for the old process to exit, then starts a fresh one. Useful after
`og-veil update` to load the new version without typing `stop && og-veil`.

- New `wait_until_stopped(pid)` daemon helper polls the live process (the
  pidfile is already removed by stop_background) so the new server doesn't
  collide with the old one on the same port.
- `restart` mirrors `serve`'s flags (host/port/tee-id/expected-pcr/pii-scrub)
  and reuses the saved login, so it never prompts.
- Update hint, docstrings, and README now point at `og-veil restart`.
- Tests cover the stop→wait→start ordering, the no-server-running path, the
  lingering-process error, and the wait helper itself.

https://claude.ai/code/session_01TYNjSYZ6QoreCr2dcURYSH
@adambalogh adambalogh marked this pull request as ready for review June 13, 2026 02:13
@adambalogh adambalogh merged commit f0a379f into main Jun 13, 2026
4 checks passed
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.

2 participants