daemon

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionProtocol = 1
	ControlProtocol = 1
)

Variables

This section is empty.

Functions

func CanonicalConfigPath

func CanonicalConfigPath(path string) (string, error)

CanonicalConfigPath resolves all existing symlink components while keeping a not-yet-created config path usable.

func ExecutableIdentity

func ExecutableIdentity() (path string, build string, err error)

func Run

func Run(ctx context.Context, opts Options) error

func Stop

func Stop(ctx context.Context, configPath string) (pidfileFallback bool, err error)

Stop asks the daemon to drain over its control connection. If the socket is unavailable or the control handshake fails, it signals only after validating every pidfile identity field.

func ValidatePIDFile

func ValidatePIDFile(record PIDFile, expectedConfigPath string) error

ValidatePIDFile checks every persisted identity field against the requested config and the currently running process. A failure is conservative: the caller must not signal the recorded PID.

Types

type ControlRequest

type ControlRequest struct {
	Command string `json:"command"`
}

type ControlResponse

type ControlResponse struct {
	OK     bool            `json:"ok"`
	Error  string          `json:"error,omitempty"`
	Status *StatusResponse `json:"status,omitempty"`
}

func Control

func Control(ctx context.Context, configPath, command string) (ControlResponse, error)

Control sends one versioned command to the daemon for configPath. Control connections intentionally do not carry or enforce the caller's build identity, so a newly installed binary can still inspect or stop an older daemon.

type Daemon

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

type Handshake

type Handshake struct {
	Type               string `json:"type"`
	Protocol           int    `json:"protocol,omitempty"`
	ControlProtocol    int    `json:"controlProtocol,omitempty"`
	Build              string `json:"build,omitempty"`
	ConfigPath         string `json:"configPath"`
	Namespace          string `json:"namespace,omitempty"`
	ExposeManagerTools bool   `json:"exposeManagerTools,omitempty"`
	Resources          bool   `json:"resources,omitempty"`
	Prompts            bool   `json:"prompts,omitempty"`
	Eager              bool   `json:"eager,omitempty"`
	// Compression is tri-state: "" = --compress absent (the active namespace's
	// configured level decides), "off" = explicit off, otherwise the level.
	Compression string `json:"compression,omitempty"`
	PID         int    `json:"pid,omitempty"`
}

type HandshakeEnvelope

type HandshakeEnvelope struct {
	Handshake Handshake `json:"mcpmu_handshake"`
}

type HandshakeResponse

type HandshakeResponse struct {
	OK               bool   `json:"ok,omitempty"`
	Error            string `json:"error,omitempty"`
	DaemonBuild      string `json:"daemonBuild,omitempty"`
	DaemonConfigPath string `json:"daemonConfigPath,omitempty"`
}

type Options

type Options struct {
	ConfigPath       string
	Build            string
	Version          string
	Revision         string
	Linger           time.Duration
	DrainTimeout     time.Duration
	HandshakeTimeout time.Duration
	OutboundQueue    int
}

type PIDFile

type PIDFile struct {
	ConfigPath           string    `json:"configPath"`
	PID                  int       `json:"pid"`
	StartedAt            time.Time `json:"startedAt"`
	ProcessStartIdentity int64     `json:"processStartIdentity"`
	ExecutablePath       string    `json:"executablePath"`
}

func ReadPIDFile

func ReadPIDFile(path string) (PIDFile, error)

type Paths

type Paths struct {
	RuntimeDir string
	Socket     string
	SpawnLock  string
	RunLock    string
	PIDFile    string
	LogFile    string
}

Paths contains every per-config daemon rendezvous artifact.

func RuntimePaths

func RuntimePaths(canonicalConfigPath string) (Paths, error)

RuntimePaths derives short rendezvous names from the canonical config path. The short hash is only a filename hint; handshakes and pidfiles retain the complete path as the authoritative identity.

type StatusResponse

type StatusResponse struct {
	Socket           string   `json:"socket"`
	Build            string   `json:"build"`
	Version          string   `json:"version"`
	Revision         string   `json:"revision"`
	ConfigPath       string   `json:"configPath"`
	PID              int      `json:"pid"`
	Sessions         int      `json:"sessions"`
	RunningUpstreams []string `json:"runningUpstreams"`
	Stopping         bool     `json:"stopping"`
}

func Inspect

func Inspect(ctx context.Context, configPath string) (status StatusResponse, pidfileFallback bool, err error)

Inspect returns live daemon status. If the control socket is unavailable, it validates the pidfile against the requested full config path and current process identity and returns a deliberately limited status snapshot.

Jump to

Keyboard shortcuts

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