Documentation
¶
Index ¶
- Variables
- func ResolveStartOrder(services []config.ServiceSpec) ([]config.ServiceSpec, error)
- type ControlServer
- type Daemon
- type HealthMonitor
- type HealthProbe
- type ManagedProcess
- type ProcessManager
- func (m *ProcessManager) IsRunning(id string) bool
- func (m *ProcessManager) RestartProcess(ctx context.Context, id string) error
- func (m *ProcessManager) RestartService(ctx context.Context, spec config.ServiceSpec) error
- func (m *ProcessManager) StartService(ctx context.Context, spec config.ServiceSpec) error
- func (m *ProcessManager) States() []ProcessState
- func (m *ProcessManager) StopAll() error
- func (m *ProcessManager) StopProcess(id string) error
- func (m *ProcessManager) StopService(serviceName string) error
- type ProcessState
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDaemonAlreadyStarted indicates Start was called while daemon is already running. ErrDaemonAlreadyStarted = errors.New("daemon already started") // ErrDaemonRestartAfterStop indicates the daemon instance was already stopped and cannot restart. ErrDaemonRestartAfterStop = errors.New("daemon cannot be restarted after Stop") )
Functions ¶
func ResolveStartOrder ¶
func ResolveStartOrder(services []config.ServiceSpec) ([]config.ServiceSpec, error)
ResolveStartOrder returns services in dependency-satisfying order. Uses Kahn's algorithm for topological sort.
Types ¶
type ControlServer ¶
type ControlServer struct {
// contains filtered or unexported fields
}
ControlServer handles daemon control-plane requests over a UDS socket.
func NewControlServer ¶
func NewControlServer(daemon *Daemon, reg *registry.Registry, logger *slog.Logger, startedAt time.Time) *ControlServer
NewControlServer creates a control server instance.
func (*ControlServer) Close ¶
func (s *ControlServer) Close() error
Close stops the control server and all active client sessions.
func (*ControlServer) Start ¶
func (s *ControlServer) Start(socketPath string) error
Start binds the unix socket and starts accepting control connections.
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon orchestrates managed services.
func (*Daemon) ProcessStates ¶
func (d *Daemon) ProcessStates() []ProcessState
ProcessStates returns current process snapshot.
func (*Daemon) RestartService ¶
RestartService restarts one configured service by name.
type HealthMonitor ¶
type HealthMonitor struct {
// contains filtered or unexported fields
}
HealthMonitor periodically checks process liveness.
func NewHealthMonitor ¶
func NewHealthMonitor( logger *slog.Logger, manager *ProcessManager, interval time.Duration, maxRestarts int, services []config.ServiceSpec, ) (*HealthMonitor, error)
NewHealthMonitor creates a health monitor.
func (*HealthMonitor) Run ¶
func (h *HealthMonitor) Run(ctx context.Context)
Run blocks and periodically logs process health status.
type HealthProbe ¶
HealthProbe checks process health beyond liveness.
type ManagedProcess ¶
type ManagedProcess struct {
// ID is the unique managed process identifier.
ID string
// Service is the owning service name.
Service string
// Spec is the configured service specification.
Spec config.ServiceSpec
// Args contains effective runtime args after instance expansion.
Args []string
// contains filtered or unexported fields
}
ManagedProcess keeps runtime state for one process instance.
type ProcessManager ¶
type ProcessManager struct {
// contains filtered or unexported fields
}
ProcessManager starts/stops and tracks service processes.
func NewProcessManager ¶
func NewProcessManager(logger *slog.Logger, stopWait time.Duration) *ProcessManager
NewProcessManager creates a process manager.
func (*ProcessManager) IsRunning ¶
func (m *ProcessManager) IsRunning(id string) bool
IsRunning reports whether process id is currently alive.
func (*ProcessManager) RestartProcess ¶
func (m *ProcessManager) RestartProcess(ctx context.Context, id string) error
RestartProcess restarts one managed process by id.
func (*ProcessManager) RestartService ¶
func (m *ProcessManager) RestartService(ctx context.Context, spec config.ServiceSpec) error
RestartService restarts every process under a service name.
func (*ProcessManager) StartService ¶
func (m *ProcessManager) StartService(ctx context.Context, spec config.ServiceSpec) error
StartService starts one service and all configured instances.
func (*ProcessManager) States ¶
func (m *ProcessManager) States() []ProcessState
States returns a snapshot of all process states.
func (*ProcessManager) StopAll ¶
func (m *ProcessManager) StopAll() error
StopAll stops all managed processes.
func (*ProcessManager) StopProcess ¶
func (m *ProcessManager) StopProcess(id string) error
StopProcess gracefully terminates a process and escalates to SIGKILL on timeout.
func (*ProcessManager) StopService ¶
func (m *ProcessManager) StopService(serviceName string) error
StopService stops all processes that belong to a service.
type ProcessState ¶
type ProcessState struct {
// ID is the unique managed process identifier.
ID string
// Service is the owning service name.
Service string
// PID is the OS process id for binary runtime, or 0 for non-process runtimes.
PID int
// Running reports whether the managed instance is currently alive.
Running bool
}
ProcessState describes a managed process state snapshot.