Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStackTrace ¶
func InstallStackTracer ¶
for debugging, show goroutine trace on receipt of USR1. uninstall by calling Stop on the returned object
Types ¶
type Lifecycle ¶
type Lifecycle struct {
// contains filtered or unexported fields
}
A Lifecycle manages some boilerplate for running daemons.
func New ¶
New creates a new Lifecycle. This should be called after validating parameters but before starting work or allocating external resources. A startup message is displayed and shutdown handlers for SIGINT and SIGTERM are registered.
If New is passed 'true' for singleProcess, it will wait for existing duplicate processes to exit before returning.
func (*Lifecycle) AddKillFunc ¶
func (l *Lifecycle) AddKillFunc(f func())
AddKillFunc will add f to the list of functions to be ran when the lifecycle is killed. Functions passed to AddKillFunc are ran in reverse order, much like defer. If the lifecycle is being killed ad the same time AddKillFunc is called, the passed function will not be called.
func (*Lifecycle) FatalQuit ¶
func (l *Lifecycle) FatalQuit()
FatalQuit will kill the lifecycle to continue into the RunWhenKilled function.
func (*Lifecycle) RunWhenKilled ¶
RunWhenKilled blocks until a shutdown signal is received, then executes finalizer and only returns either after it has finished or another shutdown signal is received. If timeout is non-zero, RunWhenKilled will force shutdown if the finalizer cannot complete within the timeout duration.
RunWhenKilled should only be called once with a master function to run on program shutdown.
RunWhenKilled runs the finalizer before any deferred AddKillFunc functions. This is so that the finalizer can begin the shutdown process that any other AddKillFunc functions can rely on.