Documentation
¶
Overview ¶
Package runtime starts, stops and observes the things Outpost supervises. A Runtime knows how to turn a manifest.Service into a running Handle; it does not decide whether something should be running — that is the supervisor's job.
Index ¶
- func OpenLog(path string) (io.WriteCloser, error)
- func WithoutSecrets(env []string) []string
- type Handle
- type ProcessRuntime
- func (r *ProcessRuntime) Healthy(ctx context.Context, handle Handle) (bool, error)
- func (r *ProcessRuntime) LogPath(service string) string
- func (r *ProcessRuntime) Logs(handle Handle) (io.ReadCloser, error)
- func (r *ProcessRuntime) Start(ctx context.Context, svc *manifest.Service) (Handle, error)
- func (r *ProcessRuntime) Stop(ctx context.Context, handle Handle) error
- type Runtime
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenLog ¶ added in v0.9.5
func OpenLog(path string) (io.WriteCloser, error)
OpenLog is a log file at path rotated as a service's is, for the daemon's own log, which has the same need to stay bounded.
func WithoutSecrets ¶ added in v0.2.0
WithoutSecrets returns env, in os.Environ form, minus the daemon's own credentials, for building a child process's environment.
Types ¶
type Handle ¶
type Handle interface {
// ID identifies the running instance: its PID.
ID() string
PID() int
Status() Status
// Done is closed once the instance has exited.
Done() <-chan struct{}
// ExitCode is meaningful only after Done is closed; it is -1 while running
// or if the instance was killed by a signal.
ExitCode() int
// CleanStop reports whether the exit was user-initiated via Stop rather
// than a crash. The supervisor keys its restart decision off this (§6.3).
CleanStop() bool
}
Handle is a reference to one started service instance. Implementations are safe for concurrent use.
type ProcessRuntime ¶
type ProcessRuntime struct {
// LogDir holds <service>.log files; defaults to ~/.outpost/logs.
LogDir string
// StopGrace is how long a service gets to exit after SIGTERM before it is
// sent SIGKILL.
StopGrace time.Duration
// HealthTimeout bounds a single healthcheck request.
HealthTimeout time.Duration
// Env is KEY=value pairs every service gets, after its manifest's own
// env so a manifest can't override them.
Env []string
// contains filtered or unexported fields
}
ProcessRuntime runs services as native child processes (§6).
func (*ProcessRuntime) Healthy ¶
Healthy probes the service's healthcheck on loopback. A non-2xx response or a transport error is a failed check, and the error explains which (§2).
func (*ProcessRuntime) LogPath ¶
func (r *ProcessRuntime) LogPath(service string) string
LogPath reports where a service's logs are written, for CLI use.
func (*ProcessRuntime) Logs ¶
func (r *ProcessRuntime) Logs(handle Handle) (io.ReadCloser, error)
Logs opens the service's current log file for reading.
type Runtime ¶
type Runtime interface {
Start(ctx context.Context, svc *manifest.Service) (Handle, error)
Stop(ctx context.Context, h Handle) error
Healthy(ctx context.Context, h Handle) (bool, error)
Logs(h Handle) (io.ReadCloser, error)
}
Runtime is the boundary the supervisor drives. ProcessRuntime implements it with os/exec, and is the only implementation: Outpost supervises native processes, not containers.