daemon

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package daemon provides the main Vision daemon orchestration. It coordinates the config, supervisor, registry, and HTTP servers.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDaemonRunning = errors.New("daemon already running")
	ErrStalePID      = errors.New("stale PID file")
)

Errors for PID file operations.

Functions

func DefaultPIDPath

func DefaultPIDPath() string

DefaultPIDPath returns the default PID file path.

func GracefulShutdown

func GracefulShutdown(d *Daemon, logger *slog.Logger) error

GracefulShutdown is a helper that sets up signal handling and waits for shutdown. This is the main entry point for running the daemon with signal handling.

Types

type Config

type Config struct {
	ConfigPath     string // Path to servers.yaml
	ManagementPort int    // Port for management API (default: 6275)
	Logger         *slog.Logger
}

Config configures the daemon.

type Daemon

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

Daemon is the main Vision daemon that coordinates all components.

func New

func New(cfg Config) (*Daemon, error)

New creates a new daemon instance.

func (*Daemon) Config

func (d *Daemon) Config() *config.Config

Config returns the current configuration.

func (*Daemon) IsRunning

func (d *Daemon) IsRunning() bool

IsRunning returns whether the daemon is running.

func (*Daemon) Registry

func (d *Daemon) Registry() *server.Registry

Registry returns the server registry.

func (*Daemon) Reload

func (d *Daemon) Reload() error

Reload reloads the configuration from disk. It starts new servers, stops removed servers, and updates changed servers.

func (*Daemon) ServerMetricsSnapshot added in v1.2.5

func (d *Daemon) ServerMetricsSnapshot(serverName string) *metrics.ServerMetricsSnapshot

ServerMetricsSnapshot returns per-server session metrics for the named server. Implements admin.ServerMetricsAccessor.

func (*Daemon) SessionLifecycleSnapshot added in v1.3.3

func (d *Daemon) SessionLifecycleSnapshot(serverName string) *admin.SessionLifecycleSnapshot

SessionLifecycleSnapshot returns the bounded secret-safe managed HTTP lifecycle projection used by both admin MCP and /v1 status surfaces.

func (*Daemon) Start

func (d *Daemon) Start() error

Start starts the daemon.

func (*Daemon) Status

func (d *Daemon) Status() DaemonStatus

Status returns the current daemon status.

func (*Daemon) Stop

func (d *Daemon) Stop(timeout time.Duration) error

Stop gracefully stops the daemon.

func (*Daemon) Wait

func (d *Daemon) Wait()

Wait blocks until the daemon stops.

type DaemonStatus

type DaemonStatus struct {
	Running    bool                  `json:"running"`
	ConfigPath string                `json:"config_path"`
	Registry   server.RegistryStatus `json:"registry"`
}

DaemonStatus contains daemon state information.

type PIDFile

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

PIDFile manages a PID file for the daemon.

func NewPIDFile

func NewPIDFile(path string) *PIDFile

NewPIDFile creates a new PID file manager.

func (*PIDFile) Acquire

func (p *PIDFile) Acquire() error

Acquire creates the PID file if no daemon is running. Returns ErrDaemonRunning if another daemon instance is active.

func (*PIDFile) AcquireOrFail

func (p *PIDFile) AcquireOrFail()

AcquireOrFail is a helper that acquires the PID file or exits with an error message.

func (*PIDFile) IsRunning

func (p *PIDFile) IsRunning() (bool, int)

IsRunning checks if a daemon is currently running.

func (*PIDFile) Path

func (p *PIDFile) Path() string

Path returns the PID file path.

func (*PIDFile) Read

func (p *PIDFile) Read() (int, error)

Read returns the PID from the file.

func (*PIDFile) Release

func (p *PIDFile) Release() error

Release removes the PID file.

type SignalHandler

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

SignalHandler manages OS signal handling for the daemon.

func NewSignalHandler

func NewSignalHandler(d *Daemon, logger *slog.Logger) *SignalHandler

NewSignalHandler creates a new signal handler for the daemon.

func (*SignalHandler) Start

func (h *SignalHandler) Start(ctx context.Context)

Start begins listening for OS signals. - SIGTERM, SIGINT: Graceful shutdown - SIGHUP: Configuration reload

func (*SignalHandler) Stop

func (h *SignalHandler) Stop()

Stop stops the signal handler.

Jump to

Keyboard shortcuts

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