Expand description
Service shutdown and lifecycle management.
Graceful shutdown of every Mountain service. Shutdown orchestrates;
ShutdownWithRecovery continues across per-service failures.
Modules§
- Dispose
Terminals Safely - Dispose every active PTY through
TerminalProvider::DisposeTerminal. Errors per terminal are collected; the loop never aborts early. - Flush
Pending Operations - Drain pending UI requests, replying with a “shutting down” error to each awaiting caller so they unblock cleanly.
- Save
Application State - Persist the global memento to disk before the runtime tears down. Creates the parent directory if missing.
- Shutdown
- Top-level shutdown orchestrator. Emits the
sky://lifecycle/willShutdownevent so Wind/Sky can flush dirty editors, dispose sockets, and cancel async tasks before the runtime tears down. Then callsShutdownWithRecoveryand logs the outcome. - Shutdown
Cocoon With Retry - Send
$shutdownover gRPC to Cocoon (3 attempts), then SIGKILL the child regardless of gRPC outcome. The hard-kill (Atom I6) is critical: a gRPC failure (transport error, broken pipe) used to leave the child orphaned, holding port 50052, and the next Mountain launch hit EADDRINUSE with the extension host stuck in degraded mode. - Shutdown
With Recovery - Robust shutdown that continues across individual service failures. Cocoon retry → terminal disposal → state save → flush. Errors collected into one summary instead of crashing.