Documentation
¶
Overview ¶
Package daemon runs drives for one user, outside any session: `f10 drive` starts the daemon when none listens, hands it the command line, and tails the drive's log. Each drive is its own child process, `f10 drive --foreground`, run in the client's directory with the client's environment, so leases and crash recovery stay the drive's own.
Index ¶
Constants ¶
const ( ReasonUpgrade = "upgrade" // the next daemon resumes it ReasonStopped = "stopped" // f10 daemon stop: it waits for its next run )
Why a drive exited ExitDrained.
const ( OpHello = "hello" OpRun = "run" OpStatus = "status" OpStop = "stop" OpWatch = "watch" )
Ops a Request names.
const ExitDrained = 6
ExitDrained is a drive's exit when it stopped for an upgrade.
const ExitNothingWatched = 7
ExitNothingWatched is a pass's exit when the project has no task left to watch: the daemon stops watching it.
const NumberFileEnv = "F10_DRIVE_FILE"
NumberFileEnv names the file a drive the daemon runs writes its record number to, once the record is open.
const Supported = false
Supported reports whether this platform runs a daemon; elsewhere drive runs in the foreground.
Variables ¶
var ErrNotRunning = errors.New("no f10 daemon is running")
ErrNotRunning is a socket nobody listens on.
var ErrRunning = errors.New("an f10 daemon is already running")
ErrRunning is a second daemon finding the first one running.
Functions ¶
func Newer ¶
Newer reports a strictly newer than b, both release versions (`0.46.0`, `v0.46.0`); a development build is newer than nothing, and nothing is newer than it, so it is replaced only by `f10 daemon stop`.
Types ¶
type Ensurer ¶
type Ensurer struct {
Dir, Version string
Spawn func(context.Context) error
Follow bool
Draining, Kept func(running string)
StartWait, DrainWait time.Duration
}
An Ensurer is unsupported here.
type Exit ¶
An Exit is how a drive's process ended: its code, why it drained, and its record number, 0 when it never opened one.
type Reply ¶
type Reply struct {
Error string `json:"error,omitempty"`
Stopping bool `json:"stopping,omitempty"` // a stop is draining it
Version string `json:"version,omitempty"`
PID int `json:"pid,omitempty"`
Started time.Time `json:"started,omitzero"`
Log string `json:"log,omitempty"` // run, logs: the drive's log; watch: the project's pass log
Attach bool `json:"attach,omitempty"` // run: the log is a drive already running
Runs []Run `json:"runs,omitempty"` // status
Watches []Watch `json:"watches,omitempty"` // status
}
A Reply answers one Request; Error set means it was refused.
type Request ¶
type Request struct {
Op string `json:"op"`
Version string `json:"version,omitempty"` // hello: the client's
Argv []string `json:"argv,omitempty"` // run: drive's arguments, --foreground added by the daemon
Dir string `json:"dir,omitempty"` // run: where the drive was typed; watch: the main checkout
Root string `json:"root,omitempty"` // run, watch: the storage root, telling projects apart
Env []string `json:"env,omitempty"` // run, watch: the allowlisted environment
Key string `json:"key,omitempty"` // run: the record's command line, joined; "" never attaches
Resume int `json:"resume,omitempty"` // run: the record --resume names
Drain bool `json:"drain,omitempty"` // stop: let each drive reach a tick boundary
Upgrade bool `json:"upgrade,omitempty"` // stop: a newer daemon follows and resumes the drained drives
}
A Request is one call: an op and what it needs.
type Run ¶
type Run struct {
Root string `json:"root"`
Dir string `json:"dir"`
Drive int `json:"drive,omitempty"` // 0 until the drive printed its number
PID int `json:"pid"`
Since time.Time `json:"since"`
Log string `json:"log"`
}
A Run is one drive process the daemon supervises.
type Server ¶
type Server struct {
Dir, Version string
Child func(argv []string) (string, []string)
Idle, DrainWait, Tick time.Duration
Log *log.Logger
}
A Server is unsupported here.
type Watch ¶
type Watch struct {
Root string `json:"root"`
Dir string `json:"dir"` // the main checkout
Last time.Time `json:"last,omitzero"` // when the last pass ended
Exit int `json:"exit"` // its exit code
Log string `json:"log"` // the project's pass log
}
A Watch is one project the daemon watches for tasks no drive owns: a `watch --pass` in its main checkout every few minutes.