Documentation
¶
Overview ¶
Package supervisor manages the lifecycle of a single supervised service process: spawning, log capture, restart policy, and graceful cancellation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultPolicy = RestartPolicy{ Mode: RestartOnFailure, MaxRestarts: 10, StartupMaxRestarts: 3, StartupGrace: 2 * time.Second, InitialDelay: 500 * time.Millisecond, MaxDelay: 30 * time.Second, ResetAfter: 60 * time.Second, }
DefaultPolicy matches the defaults in the Rust implementation.
Functions ¶
func PIDFilePath ¶
PIDFilePath returns the path to the devrig master PID file.
func WritePIDFile ¶
WritePIDFile writes the current process PID to the state directory.
Types ¶
type RestartMode ¶
type RestartMode int
RestartMode determines when a process should be restarted.
const ( RestartOnFailure RestartMode = iota // restart only on non-zero exit RestartAlways // restart regardless of exit code RestartNever // never restart )
type RestartPolicy ¶
type RestartPolicy struct {
Mode RestartMode
MaxRestarts uint32
StartupMaxRestarts uint32
StartupGrace time.Duration
InitialDelay time.Duration
MaxDelay time.Duration
ResetAfter time.Duration
}
RestartPolicy holds all tuning knobs for the restart loop.
func PolicyFromConfig ¶
func PolicyFromConfig(cfg *config.RestartConfig) RestartPolicy
PolicyFromConfig converts a config RestartConfig to a RestartPolicy.
type Supervisor ¶
type Supervisor struct {
Name string
Command string
WorkingDir string
Env map[string]string
Policy RestartPolicy
// contains filtered or unexported fields
}
Supervisor manages a single service process.
func New ¶
func New( name, command, workingDir string, env map[string]string, policy RestartPolicy, logs *events.Broadcaster, evts *events.Broadcaster, stateDir string, ) *Supervisor
New creates a Supervisor.
Click to show internal directories.
Click to hide internal directories.