Documentation
¶
Index ¶
Constants ¶
View Source
const ( OutputTypeStdout = "stdout" OutputTypeStderr = "stderr" OutputTypeNull = "null" OutputTypeFile = "file" )
View Source
const ( // RestartNever indicates to never restart the process RestartNever = RestartPolicy("never") // RestartOnFailure indicates to only restart the process after failures RestartOnFailure = RestartPolicy("on_failure") // RestartAlways indicates to always restart the process RestartAlways = RestartPolicy("always") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
Supervise []Definition `json:"supervise,omitempty"`
// contains filtered or unexported fields
}
func (App) CaddyModule ¶
func (a App) CaddyModule() caddy.ModuleInfo
CaddyModule implements caddy.Module
type Definition ¶
type Definition struct {
// Command to start and supervise. First item is the program to start, others are arguments.
// Supports template.
Command []string `json:"command"`
// Replicas control how many instances of Command should run.
Replicas *int `json:"replicas,omitempty"`
// Dir defines the working directory the command should be executed in.
// Supports template.
// Default: current working dir
Dir string `json:"dir,omitempty"`
// Env declares environment variables that should be passed to command.
// Supports template.
Env map[string]string `json:"env,omitempty"`
// RedirectStdout is the file where Command stdout is written. Use "stdout" to redirect to caddy stdout.
RedirectStdout *OutputTarget `json:"redirect_stdout,omitempty"`
// RedirectStderr is the file where Command stderr is written. Use "stderr" to redirect to caddy stderr.
RedirectStderr *OutputTarget `json:"redirect_stderr,omitempty"`
// RestartPolicy define under which conditions the command should be restarted after exit.
// Valid values:
// - **never**: do not restart the command
// - **on_failure**: restart if exit code is not 0
// - **always**: always restart
RestartPolicy RestartPolicy `json:"restart_policy,omitempty"`
// TerminationGracePeriod defines the amount of time to wait for Command graceful termination before killing it. Ex: 10s
TerminationGracePeriod string `json:"termination_grace_period,omitempty"`
// User defines the user which executes the Command.
// Default: current user
User string `json:"user,omitempty"`
StopSignal string `json:"stop_signal,omitempty"`
}
Definition is the configuration for process to supervise
func (Definition) ToSupervisors ¶
func (d Definition) ToSupervisors(logger *zap.Logger) ([]*Supervisor, error)
ToSupervisors creates supervisors from the Definition (one per replica) and applies templates where needed
type Options ¶
type Options struct {
Command string
Replica int
Args []string
Dir string
Env []string
RedirectStdout OutputTarget
RedirectStderr OutputTarget
RestartPolicy RestartPolicy
TerminationGracePeriod time.Duration
User string
StopSignal os.Signal
}
Options exposes settings to create a process supervisor
type OutputTarget ¶
type OutputTarget struct {
// Type is how the output should be redirected
// Valid values:
// - **null**: discard outputs
// - **stdout**: redirect output to caddy process stdout
// - **stderr**: redirect output to caddy process stderr
// - **file**: redirect output to a file, if selected File field is required
Type string `json:"type,omitempty"`
// File is the file where outputs should be written. This is used only when Type is "file".
File string `json:"file,omitempty"`
}
type RestartPolicy ¶
type RestartPolicy string
RestartPolicy determines when a supervised process should be restarted
type Supervisor ¶
type Supervisor struct {
Options Options
// contains filtered or unexported fields
}
Supervisor provides functionality to start and supervise a background process
Click to show internal directories.
Click to hide internal directories.