Documentation
¶
Overview ¶
Package monitor implements a self-monitoring auto-restart mechanism.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsMonitored ¶
IsMonitored returns true if current process is being monitored to restart automatically.
func SelfMonitor ¶
SelfMonitor creates another instance of the current program and watches it to auto-restart on failures till the input context is expired. When the input context is expired, existing child process will be signaled to shutdown and the function returns a non-nil error.
The input `envKey` must be an application-specific, unique non-empty environment variable name, which is used internally to distinguish between the monitor instance and the monitored instance. A temporary http server URL is stored in the envKey value, which can optionally receive child processes' initialization status.
Types ¶
type Options ¶
type Options struct {
ShutdownSignal os.Signal // Defaults to os.Interrupt
ShutdownTimeout time.Duration // Defaults to 10 seconds.
MinBackoffTimeout time.Duration // Defaults to one second.
MaxBackoffTimeout time.Duration // Defaults to one minute.
}
Options defines the user configurable values for the Monitor.