control

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package control implements the file-based control plane shared between the daemon and the CLI/TUI: the daemon publishes status.json each tick, clients write override.json (watched by the daemon), and a single-instance lock prevents two daemons running against the same runtime directory.

Index

Constants

View Source
const (
	StatusFile   = "status.json"
	OverrideFile = "override.json"
	LockFile     = "daemon.lock"
	LogFile      = "vigil.log"
)

File names within the runtime directory.

Variables

View Source
var ErrNoStatus = errors.New("no daemon status found (is the service running?)")

ErrNoStatus indicates the daemon has not published a status yet.

Functions

func LockPath

func LockPath(runtimeDir string) string

LockPath returns the lock file path within runtimeDir.

func LogPath

func LogPath(runtimeDir string) string

LogPath returns the log file path within runtimeDir.

func OverridePath

func OverridePath(runtimeDir string) string

OverridePath returns the override.json path within runtimeDir.

func StatusPath

func StatusPath(runtimeDir string) string

StatusPath returns the status.json path within runtimeDir.

func WriteStatus

func WriteStatus(runtimeDir string, s Status) error

WriteStatus atomically writes the status to runtimeDir/status.json.

Types

type Lock

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

Lock represents a held single-instance lock.

func AcquireLock

func AcquireLock(runtimeDir string) (*Lock, bool, error)

AcquireLock takes an exclusive non-blocking lock in runtimeDir. It returns a nil Lock and false if another daemon already holds it.

func (*Lock) Release

func (l *Lock) Release() error

Release releases the lock.

type Status

type Status struct {
	PID           int        `json:"pid"`
	Engine        string     `json:"engine"`
	Activators    []string   `json:"activators"`
	DesiredActive bool       `json:"desired_active"`
	OverrideMode  string     `json:"override_mode"`
	OverrideUntil *time.Time `json:"override_until,omitempty"`
	LastTick      *time.Time `json:"last_tick,omitempty"`
	LastError     string     `json:"last_error,omitempty"`
	NextChange    *time.Time `json:"next_change,omitempty"`
	NextActive    bool       `json:"next_active"`
	UpdatedAt     time.Time  `json:"updated_at"`
	StartedAt     time.Time  `json:"started_at"`
}

Status is the daemon's published state, read by `status` and the TUI.

func ReadStatus

func ReadStatus(runtimeDir string) (Status, error)

ReadStatus reads runtimeDir/status.json.

Jump to

Keyboard shortcuts

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