watchdog

package
v0.0.0-...-0eacd2e Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 4 Imported by: 25

README

Watchdog

The watchdog is in charge of ensuring that a list of programs are always running. The watchdog will start these programs (it will be the parent of those processes). If the watchdog is terminated, the monitored programs will also be terminated.

When the watchdog starts up, it will kill any programs that it will be monitoring. Then it will monitor a list of programs and will restart them if they exit. Programs can be configured to always run, or to stop when receiving a particular exit status.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Watch

func Watch(programs []Program, restartDelay time.Duration, log Log) error

Types

type ExitOn

type ExitOn string

ExitOn describes when a program should exit (not-restart)

const (
	// ExitOnNone means the program should always be restarted
	ExitOnNone ExitOn = ""
	// ExitOnSuccess means the program should only restart if errored
	ExitOnSuccess ExitOn = "success"
	// ExitAllOnSuccess means the program should only restart if errored,
	// otherwise exit this watchdog. Intended for Windows
	ExitAllOnSuccess ExitOn = "all"
)

type Log

type Log interface {
	Debugf(s string, args ...interface{})
	Infof(s string, args ...interface{})
	Warningf(s string, args ...interface{})
	Errorf(s string, args ...interface{})
}

Log is the logging interface for the watchdog package

type Program

type Program struct {
	Path   string
	Name   string
	Args   []string
	ExitOn ExitOn
	// contains filtered or unexported fields
}

Program is a program at path with arguments

func (*Program) Run

func (p *Program) Run(log Log, shutdownCh chan struct{}) (err error)

type Watchdog

type Watchdog struct {
	Programs     []Program
	RestartDelay time.Duration
	Log          Log
	// contains filtered or unexported fields
}

func (*Watchdog) Shutdown

func (w *Watchdog) Shutdown()

Jump to

Keyboard shortcuts

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