Skip to main content

Module Shutdown

Module Shutdown 

Source
Expand description

Service shutdown and lifecycle management. Graceful shutdown of every Mountain service. Shutdown orchestrates; ShutdownWithRecovery continues across per-service failures.

Modules§

DisposeTerminalsSafely
Dispose every active PTY through TerminalProvider::DisposeTerminal. Errors per terminal are collected; the loop never aborts early.
FlushPendingOperations
Drain pending UI requests, replying with a “shutting down” error to each awaiting caller so they unblock cleanly.
SaveApplicationState
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/willShutdown event so Wind/Sky can flush dirty editors, dispose sockets, and cancel async tasks before the runtime tears down. Then calls ShutdownWithRecovery and logs the outcome.
ShutdownCocoonWithRetry
Send $shutdown over 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.
ShutdownWithRecovery
Robust shutdown that continues across individual service failures. Cocoon retry → terminal disposal → state save → flush. Errors collected into one summary instead of crashing.