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 ¶
const ( StatusFile = "status.json" OverrideFile = "override.json" LockFile = "daemon.lock" LogFile = "vigil.log" )
File names within the runtime directory.
Variables ¶
var ErrNoStatus = errors.New("no daemon status found (is the service running?)")
ErrNoStatus indicates the daemon has not published a status yet.
Functions ¶
func OverridePath ¶
OverridePath returns the override.json path within runtimeDir.
func StatusPath ¶
StatusPath returns the status.json path within runtimeDir.
func WriteStatus ¶
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 ¶
AcquireLock takes an exclusive non-blocking lock in runtimeDir. It returns a nil Lock and false if another daemon already holds it.
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 ¶
ReadStatus reads runtimeDir/status.json.