daemon

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package daemon supervises an auxiliary process that runs alongside a cluster: it starts the process, waits until the process is actually serving, and terminates it. It knows nothing about any particular daemon.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name       string // used in error messages; defaults to the binary's base name
	BinaryPath string
	Args       []string
	Env        []string // appended to the parent environment
	Dir        string
	// Ready decides when Start may return. A nil Probe means the process is
	// considered ready as soon as it is alive.
	Ready     Probe
	ReadyWait time.Duration // defaults to defaultReadyWait
}

Config describes one process to supervise.

type Daemon

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

Daemon is a running supervised process.

func Start

func Start(ctx context.Context, cfg Config) (*Daemon, error)

Start launches the process and returns once it is ready.

Readiness races three outcomes: the probe succeeds, the process exits, or the deadline passes. Watching for the exit matters as much as the probe: a daemon that opens its port and then dies would otherwise leave the caller blocked for the whole deadline with no explanation.

func (*Daemon) Output

func (d *Daemon) Output() string

Output returns everything the process has written to stdout and stderr.

func (*Daemon) Stop

func (d *Daemon) Stop() error

Stop terminates the process and waits for it to be reaped. Safe to call more than once and safe to call on a process that has already exited.

type Probe

type Probe func(context.Context) error

Probe reports whether the process is serving yet. It is called repeatedly until it returns nil, the process exits, or the deadline passes.

Jump to

Keyboard shortcuts

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