Help us shape the future of Go! Take the 2026 Go Developer Survey

daemon

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package daemon manages the Vela watch daemon lifecycle: PID file management, process detection, start/stop/status operations, and service installation.

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyRunning = errors.New("daemon is already running")

ErrAlreadyRunning is returned when a start operation finds a daemon already running.

View Source
var ErrNotRunning = errors.New("daemon is not running")

ErrNotRunning is returned when a stop/status operation finds no running daemon.

Functions

func InstallService

func InstallService(pidFile, logFile string) error

InstallService installs the Vela watch daemon as a system service. On Linux it creates a systemd user unit; on macOS a launchd plist.

func ServiceInstalled added in v1.2.0

func ServiceInstalled() bool

ServiceInstalled reports whether the user-level service definition exists on the current platform.

func SetConfigLoader

func SetConfigLoader(fn func() (*types.Config, error))

SetConfigLoader registers the function the daemon uses to reload config on SIGHUP. Call this before daemon.Start(). Keeps daemon package free of a direct import on internal/config (avoids circular dependency risk).

func UninstallService

func UninstallService() error

UninstallService removes the installed system service.

Types

type Daemon

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

Daemon orchestrates the Vela watch subsystem: it manages listener lifecycle, feeds events through the reconciler pipeline, and drives LLM extraction.

func New

func New(cfg *types.Config, g *igraph.Graph) (*Daemon, error)

New creates a Daemon from the provided configuration and graph. The graph is patched in-place as events arrive.

func (*Daemon) Registry

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

Registry returns the listener registry for status queries.

func (*Daemon) SetGraphPath added in v1.3.0

func (d *Daemon) SetGraphPath(path string)

SetGraphPath sets the path where the daemon will persist graph.json. Call this before daemon.Start(). When empty, graph persistence is skipped.

func (*Daemon) Start

func (d *Daemon) Start(ctx context.Context) error

Start launches the daemon. It returns ErrAlreadyRunning if a daemon is already running (PID file exists and process is alive).

func (*Daemon) Status

func (d *Daemon) Status() string

Status returns a human-readable status string for the daemon. When called cross-process it reads the status file written by statusLoop.

func (*Daemon) Stop

func (d *Daemon) Stop() error

Stop shuts the daemon down cleanly and removes the PID file.

type PIDFile

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

PIDFile manages a file that stores the PID of the running daemon.

func NewPIDFile

func NewPIDFile(path string) (*PIDFile, error)

NewPIDFile creates a PIDFile for the given path. The directory is created if it does not exist.

func (*PIDFile) IsAlive

func (p *PIDFile) IsAlive() (bool, int, error)

IsAlive returns true if the recorded PID corresponds to a running process.

func (*PIDFile) Read

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

Read returns the PID stored in the file. Returns ErrNotRunning if the file does not exist.

func (*PIDFile) Remove

func (p *PIDFile) Remove() error

Remove deletes the PID file (called on clean shutdown).

func (*PIDFile) Write

func (p *PIDFile) Write() error

Write records the current process PID into the file.

func (*PIDFile) WritePID

func (p *PIDFile) WritePID(pid int) error

WritePID records an arbitrary PID into the file (used when fork-exec'ing).

Jump to

Keyboard shortcuts

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