daemon

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateNextInterval

func CalculateNextInterval(rate int, period string) (time.Duration, error)

CalculateNextInterval returns a random duration for the next trigger Based on rolling randomness: random value between 0.5x and 1.5x the average interval

func CalculateNextTrigger

func CalculateNextTrigger(rate int, period string) (time.Time, error)

CalculateNextTrigger returns the time for the next entry trigger

func IsRunning

func IsRunning() (bool, int, error)

IsRunning checks if a daemon process is currently running

func PIDPath

func PIDPath() (string, error)

PIDPath returns the path to the daemon PID file

func PeriodToDuration

func PeriodToDuration(period string) (time.Duration, error)

PeriodToDuration converts a rate period string to a time.Duration

func ReadPID

func ReadPID() (int, error)

ReadPID reads the PID from the PID file

func RemovePID

func RemovePID() error

RemovePID removes the PID file

func RemoveState

func RemoveState() error

RemoveState removes the state file

func SaveState

func SaveState(state *State) error

SaveState writes the daemon state to disk

func StatePath

func StatePath() (string, error)

StatePath returns the path to the daemon state file

func StopRunning

func StopRunning() error

StopRunning sends SIGTERM to the running daemon

func WritePID

func WritePID() error

WritePID writes the current process ID to the PID file

Types

type Daemon

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

Daemon manages autonomous journal entry generation

func New

func New(cfg *config.Config) *Daemon

New creates a new daemon instance

func (*Daemon) Start

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

Start begins the daemon's main loop

func (*Daemon) Stop

func (d *Daemon) Stop()

Stop signals the daemon to shut down gracefully

func (*Daemon) Wait

func (d *Daemon) Wait()

Wait blocks until the daemon has fully stopped

type State

type State struct {
	PID              int       `json:"pid"`
	StartedAt        time.Time `json:"started_at"`
	NextTrigger      time.Time `json:"next_trigger"`
	EntriesGenerated int       `json:"entries_generated"`
	LastEntryAt      time.Time `json:"last_entry_at,omitempty"`
	LastPersona      string    `json:"last_persona,omitempty"`
}

State holds the daemon's runtime state

func LoadState

func LoadState() (*State, error)

LoadState reads the daemon state from disk

Jump to

Keyboard shortcuts

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