coprocess

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const PluginName string = "coprocess"

PluginName contains the name/id of the plugin.

Variables

This section is empty.

Functions

func Metadata

func Metadata(_ api.Settings) map[string]interface{}

Metadata passed to nginx-wrapper initialization.

func New

func New(name string, exec []string, stopExec []string, user string, restarts string, timeBetweenRestarts string,
	background bool, execEvent string, stopEvent string, settings api.Settings) (Coprocess, *InitError)

New creates a new instance of Coprocess and validates that the passed parameters are valid.

func Start

func Start(context api.PluginStartupContext) error

Start is invoked by nginx-wrapper to start the plugin.

Types

type Coprocess

type Coprocess struct {
	Name               string
	Exec               []string
	StopExec           []string
	User               string
	Restarts           RestartPolicy
	TimeBetweenRestart time.Duration
	Background         bool
	ExecEvent          string
	StopEvent          string
	Done               *abool.AtomicBool
	// contains filtered or unexported fields
}

Coprocess represents a process that will run alongside nginx and be tied to a nginx start event and stop event.

func (*Coprocess) ExecuteCoprocess

func (c *Coprocess) ExecuteCoprocess() error

ExecuteCoprocess invokes the associated process and optionally runs it repeatedly according to the associated restart policy.

func (*Coprocess) ExecuteStopCmd

func (c *Coprocess) ExecuteStopCmd() error

ExecuteStopCmd executes the optional command associated with the coprocess to run when the stop event is encountered.

func (*Coprocess) MaxRestarts

func (c *Coprocess) MaxRestarts() int

MaxRestarts returns the maximum number of restarts for the associated process with -1 indicating an unlimited amount of restarts.

func (*Coprocess) SleepBetweenRestarts added in v0.0.2

func (c *Coprocess) SleepBetweenRestarts()

SleepBetweenRestarts waits for a configured duration until continuing.

func (Coprocess) String

func (c Coprocess) String() string

func (*Coprocess) TerminateCoprocess

func (c *Coprocess) TerminateCoprocess() error

TerminateCoprocess terminates the associated coprocess by sending (in this order) SIGTERM, SIGINT, or SIGKILL until the process exits.

type InitError

type InitError struct {
	InitFailureMessages []string
	ConfigSectionName   string
}

InitError is throw when a Coprocess instance can't be instantiated.

func (*InitError) Error

func (e *InitError) Error() string

type RestartPolicy

type RestartPolicy string

RestartPolicy represents what we do when a process has stopped. Valid values are defined in the constants below or alternatively an integer value represented as a string.

const (
	// Unlimited restart policy means that the process will always be restarted if it exits.
	Unlimited RestartPolicy = "unlimited"
	// Never restart policy means that the process will never be restarted if it exits.
	Never RestartPolicy = "never"
	// Terminating restart policy means that the wrapper is attempting to end the process.
	Terminating RestartPolicy = "terminating"
)

Jump to

Keyboard shortcuts

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