shutdown

package
v1.142.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package shutdown is what a shutdown does with the work still in flight (#2058): the drains components register to stop taking new work and finish what they hold, run in the background from the signal beside the HTTP drain, and the close of live MCP sessions that sends connected agents to the new build while leaving the in-process sessions to the work they carry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseSessions

func CloseSessions(ctx context.Context, mcpServer *mcp.Server)

CloseSessions closes every live MCP session so connected clients drop their stale connection and reconnect to the new build (#675). Claude Code auto-reconnects HTTP/SSE servers and re-handshakes (fresh tools/list); Claude Desktop requires an app restart.

ServerSession.Close is graceful: an idle session's long-lived SSE/streamable stream drops immediately, but a session with an in-flight tool call blocks until that call returns, and that wait is not bounded by the HTTP grace period. So the closes run in a goroutine bounded by ctx (the shutdown deadline): if they do not all finish in time, we return and let process exit drop the remaining connections rather than hang past terminationGracePeriodSeconds and risk a SIGKILL mid-call.

func InBackground

func InBackground(drain func(context.Context) error, budget time.Duration) <-chan struct{}

InBackground starts drain under a budget of its own and returns a channel closed when it has returned. A nil drain is closed at once.

Types

type Drains

type Drains struct {
	// contains filtered or unexported fields
}

Drains is the set of drains a lifecycle runs before it stops its components: each stops taking new work and finishes what it holds, bounded by the context it is given. A managed-script run claimed seconds before a SIGTERM finishes in its drain instead of being cut off; what a drain does not finish is the component's stop to release. The zero value is ready.

func (*Drains) Add

func (d *Drains) Add(drain func(context.Context) error)

Add registers a drain. Nil is ignored.

func (*Drains) Run

func (d *Drains) Run(ctx context.Context) error

Run runs every drain concurrently and returns when all have, which each does by ctx's deadline at the latest. Their errors are joined.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL