supervisor

package
v0.0.0-...-0226060 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

gateway.go — external gateway subprocess lifecycle management.

Built-in gateways (type: cron, type: webhook) are handled entirely within the Gitai process by gateway.Manager and control.Server respectively. External gateways — those whose Gosuto spec includes a Command field — are separate binaries that run as supervised child processes, similar to MCP servers.

Each external gateway process receives a standard set of injected environment variables so it knows where to deliver events:

GATEWAY_TARGET_URL   — http://127.0.0.1:{port}/events/{name}
                       The ACP endpoint the binary must POST event envelopes to.
GATEWAY_<KEY>        — one var per gateway config entry (key uppercased).

The supervisor mirrors the Supervisor pattern: Reconcile() brings running processes in line with the active Gosuto spec, and Stop() tears everything down cleanly. If autoRestart is true in the Gateway spec, the process is automatically restarted after a brief delay when it exits unexpectedly.

Package supervisor manages the lifecycle of MCP server sub-processes. It starts each server described in the active Gosuto config, restarts them on unexpected exit when auto_restart is set, and provides a lookup from server name to a live mcp.Client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExternalGatewaySupervisor

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

ExternalGatewaySupervisor manages the lifecycle of external gateway processes. Only Gateway entries with a non-empty Command field are handled here; built-in gateway types ("cron", "webhook") are managed elsewhere and are silently ignored by Reconcile.

func NewExternalGatewaySupervisor

func NewExternalGatewaySupervisor(acpURL string) *ExternalGatewaySupervisor

NewExternalGatewaySupervisor creates an ExternalGatewaySupervisor whose managed processes will POST events to acpURL (e.g. "http://127.0.0.1:8765").

func (*ExternalGatewaySupervisor) ApplySecrets

func (s *ExternalGatewaySupervisor) ApplySecrets(env map[string]string)

ApplySecrets updates the environment variables injected into newly-started gateway processes. Existing processes are NOT restarted — call Reconcile after ApplySecrets if you want the running processes to pick up the changes.

func (*ExternalGatewaySupervisor) Reconcile

func (s *ExternalGatewaySupervisor) Reconcile(gateways []gosutospec.Gateway)

Reconcile ensures exactly the external gateways described in gateways are running. Built-in gateway types (type: cron, type: webhook) are silently skipped — they are managed by gateway.Manager and control.Server.

Processes no longer in the spec, or whose config has changed, are stopped before the new version is started.

func (*ExternalGatewaySupervisor) State

func (*ExternalGatewaySupervisor) Stop

func (s *ExternalGatewaySupervisor) Stop()

Stop cancels all external gateway processes and waits for them to exit.

type ProcessHealth

type ProcessHealth string
const (
	HealthStarting    ProcessHealth = "starting"
	HealthRunning     ProcessHealth = "running"
	HealthBackoff     ProcessHealth = "backoff"
	HealthCircuitOpen ProcessHealth = "circuit_open"
	HealthStopped     ProcessHealth = "stopped"
)

type ProcessState

type ProcessState struct {
	Name         string
	PID          int
	StartedAt    time.Time
	ExitedAt     time.Time
	ExitError    string
	RestartCount int
	NextRetry    time.Time
	Health       ProcessHealth
}

type Supervisor

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

Supervisor manages a set of MCP server processes.

func New

func New() *Supervisor

New creates a Supervisor with no servers running yet.

func (*Supervisor) ApplySecrets

func (s *Supervisor) ApplySecrets(env map[string]string)

ApplySecrets updates the environment injected into MCP processes. Running processes are restarted so they pick up refreshed credentials.

func (*Supervisor) Get

func (s *Supervisor) Get(name string) *mcp.Client

Get returns the live mcp.Client for the named server, or nil.

func (*Supervisor) Names

func (s *Supervisor) Names() []string

Names returns all currently running MCP server names.

func (*Supervisor) Reconcile

func (s *Supervisor) Reconcile(specs []gosutospec.MCPServer)

Reconcile ensures that exactly the servers in specs are running. Servers no longer in the new spec are stopped; new ones are started.

func (*Supervisor) State

func (s *Supervisor) State(name string) (ProcessState, bool)

func (*Supervisor) Stop

func (s *Supervisor) Stop()

Stop shuts down all managed MCP processes.

Jump to

Keyboard shortcuts

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