Documentation
¶
Overview ¶
Package runnerstate holds the local single-runner protocol shared by the runner and its detached starter. Pids alone are never liveness evidence.
Index ¶
- Constants
- func Acquire(dir string) (func(), error)
- func AppendAgent(dir, line string) error
- func ClearRestart(dir string) error
- func ClearStale(dir string) (pid int, cleared bool, err error)
- func LoadAgents(dir string) ([]string, error)
- func LoadForeman(dir string) (string, error)
- func LoadParallel(dir string) (int, error)
- func MigrateForeman(dir string) error
- func Publish(dir string, agents []api.Agent, specs ...string) error
- func PublishParallel(dir string, agents []api.Agent, parallel int, specs ...string) error
- func RequestRestart(dir, mode string) error
- func RestartRequested(dir string) (string, bool)
- func SaveAgents(dir string, specs []string) error
- func SaveForeman(dir, foreman string) error
- func SaveParallel(dir string, n int) error
- func StalePIDs(dir string) []int
- type Record
Constants ¶
const ( RestartDrain = "drain" RestartNow = "now" )
The restart request modes: RestartDrain has the runner take no new lease and exit once its running jobs finish; RestartNow has it exit at once, cutting them.
Variables ¶
This section is empty.
Functions ¶
func AppendAgent ¶
AppendAgent adds one line to the agents file and keeps every line already in it, comments and lines it does not understand included.
func ClearRestart ¶
ClearRestart removes the restart request: the runner that honoured it, and the starter of the next one, leave nothing pending behind.
func ClearStale ¶
ClearStale clears a previous runner's pid and metadata only while holding the runner lock. A busy lock returns the live pid and an error wrapping EWOULDBLOCK/EAGAIN: a runner is starting or running, so nothing is cleared. The lock file stays in place; removing it could split starters across two files.
func LoadAgents ¶
LoadAgents reads the durable choices, independently of runner liveness. A nil slice means init has not saved choices yet.
func LoadForeman ¶
LoadForeman reads the foreman init saved, as harness/model[@effort]. It is empty when init has not saved one yet.
func LoadParallel ¶
LoadParallel returns the saved init choice, or zero when none was saved.
func MigrateForeman ¶
MigrateForeman moves a foreman choice saved as the file "foreman" to its current name, freeing the path for the foreman's scratch directory. A directory there is the scratch directory and stays; a choice already saved under the current name wins over the old file.
Foreman turns and attaches may migrate at once: a call that loses the race to another finds no old file left and succeeds.
func PublishParallel ¶
PublishParallel records the live runner capacity beside its agents.
func RequestRestart ¶
RequestRestart leaves a restart request for the runner in dir: a small JSON file it honours between jobs — drain finishes its running jobs first, now stops at once. A runner already draining ignores a second request; the fresh starter clears what it finds.
func RestartRequested ¶
RestartRequested reads the pending restart request: its mode, and whether one is pending at all. A file that cannot be read or parsed counts as none — the runner never exits on a request it cannot understand.
func SaveAgents ¶
SaveAgents atomically replaces the private, durable runner choices. The live runner.json record is published separately by the runner itself.
func SaveForeman ¶
SaveForeman atomically replaces the private, durable foreman choice.
func SaveParallel ¶
SaveParallel atomically saves init's private, durable concurrency choice.