Add graceful SIGTERM/SIGINT shutdown to server + UI binaries #7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Context
Neither
crates/hero_livekit_server/src/main.rsnorcrates/hero_livekit_ui/src/main.rshandles SIGTERM or SIGINT. On container/k3s termination this leaves stale Unix sockets and truncates in-flight requests.rust_shutdownsignalsmandates graceful shutdown + socket cleanup for every Hero daemon.Goals
tokio::signal::unix::{signal, SignalKind}for SIGTERM and SIGINT in both binaries.with_graceful_shutdown(or equivalenthyperAPI) for the UI HTTP server.Related skills:
rust_shutdownsignals.Implementation Spec for Issue #7
Objective
Add graceful SIGTERM/SIGINT shutdown handling to both hero_livekit_server and hero_livekit_ui binaries, ensuring Unix socket files are cleaned up on termination.
Requirements
Files to Modify
crates/hero_livekit_ui/src/main.rs- Add shutdown_signal(), restructure main() to spawn accept loop, await signal, cleanup socketcrates/hero_livekit_server/src/main.rs- Add shutdown_signal(), service_socket_path(), wrap OServer::run_cli() in tokio::select! with socket cleanupImplementation Plan
Step 1: Add graceful shutdown to hero_livekit_ui
Files:
crates/hero_livekit_ui/src/main.rsDependencies: none
Step 2: Add graceful shutdown to hero_livekit_server
Files:
crates/hero_livekit_server/src/main.rsDependencies: none
Acceptance Criteria
Notes
Test Results
All workspace tests pass after adding graceful shutdown to both binaries.
Implementation Summary
Changes Made
hero_livekit_ui (crates/hero_livekit_ui/src/main.rs)
shutdown_signal()async function that listens for SIGINT (Ctrl+C) and SIGTERMmain(): the Axum accept loop now runs in atokio::spawntaskui.sockis cleaned uptracing::info!hero_livekit_server (crates/hero_livekit_server/src/main.rs)
shutdown_signal()async function (same SIGINT/SIGTERM pattern)service_socket_path()helper to resolverpc.sockunder$HERO_SOCKET_DIROServer::run_cli()in atokio::spawntask withtokio::select!againstshutdown_signal()abort_handlepattern to safely cancel the server task from the signal branchrpc.sockTest Results
Notes
#[cfg(not(unix))]fallback ensures the code compiles on non-Unix platforms (pending forever)