runner

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const LogTimestampLayout = "2006-01-02T15-04-05"

LogTimestampLayout is shared so a log filename can be parsed back into its time with the exact layout used to format it.

Variables

This section is empty.

Functions

func InFlight

func InFlight(job string) (logName string, running bool)

InFlight reports whether a Run holds the Job's lock and, while the agent is streaming, the name of the log file it is writing to. The name is empty during an earlier Condition check, before the agent's log exists.

func IsRunning

func IsRunning(job string) bool

IsRunning reports whether a Run currently holds the Job's lock. It is a best-effort, non-destructive probe of the same flock acquireLock takes: a successful try-lock (released at once) means no Run is in flight, EWOULDBLOCK means one is. The result is advisory; a firing can still begin the instant after it returns. It opens without O_CREATE so probing a Job that has never run reports false rather than littering a lock file.

func RunningSince

func RunningSince(job string) (time.Time, bool)

RunningSince reports whether a Run is in flight for the Job and, when known, when it started. The start time is parsed from the in-flight Run's log file name; it is unknown (zero) during an earlier Condition check, before the agent's log exists. The name is stamped from a local time.Now(), so it parses back in time.Local to recover the true instant (not just the right digits).

Types

type Reason

type Reason string

Reason qualifies a Run's status when the agent did not produce it: the firing was dropped (ReasonOverlap, or ReasonCondition for a clean skip), or the condition check itself broke or was interrupted (ReasonCondition with StatusFailure or StatusInterrupted). ReasonNone is the zero value, used when the agent ran — whether it produced the status or an interrupt aborted it.

const (
	ReasonNone      Reason = ""
	ReasonOverlap   Reason = "overlap"
	ReasonCondition Reason = "condition"
)

type Record

type Record struct {
	Start     string `json:"start"`
	End       string `json:"end"`
	Status    Status `json:"status"`
	Reason    Reason `json:"reason,omitempty"`
	Exit      int    `json:"exit"`
	DurationS int    `json:"duration_s"`
	Log       string `json:"log"`
}

func History

func History(job string) ([]Record, error)

func LastRecord

func LastRecord(job string) (Record, bool, error)

type Result

type Result struct {
	Status   Status
	Reason   Reason
	Exit     int
	Duration time.Duration
	LogPath  string
	Command  []string // resolved agent argv, nil when the agent never ran
}

func Run

func Run(ctx context.Context, job config.Job) (Result, error)

Run executes the Job's optional condition then its agent, bounded by the Job's timeout. ctx carries the caller's interrupt (SIGINT/SIGTERM in the `acron run` path): cancelling it records the in-flight Run as interrupted and releases the lock, distinct from a deliberate skip or a failure.

type Status

type Status string
const (
	StatusSuccess     Status = "success"
	StatusFailure     Status = "failure"
	StatusTimeout     Status = "timeout"
	StatusSkipped     Status = "skipped"
	StatusInterrupted Status = "interrupted"
)

Jump to

Keyboard shortcuts

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