Documentation ¶
Overview ¶
Package graceful provides a mechanism to gracefully stop processes on os signals.
Index ¶
Constants ¶
This section is empty.
Variables ¶
DefaultShutdownSignals are the default os signals to capture to shut down.
Functions ¶
func Notify ¶ added in v1.20201204.1
Notify returns a channel that listens for a given set of os signals.
func Shutdown ¶
Shutdown racefully stops a set hosted processes based on SIGINT or SIGTERM received from the os. It will return any errors returned by Start() that are not caused by shutting down the server. A "Graceful" processes *must* block on start.
func ShutdownBySignal ¶
func ShutdownBySignal(hosted []Graceful, opts ...ShutdownOption) error
ShutdownBySignal gracefully stops a set hosted processes based on a set of variadic options. A "Graceful" processes *must* block on start. Fatal errors will be returned, that is, errors that are returned by either .Start() or .Stop(). Panics are not caught by graceful, and it is assumed that your .Start() or .Stop methods will catch relevant panics.
Types ¶
type ShutdownOption ¶ added in v1.20201204.1
type ShutdownOption func(*ShutdownOptions)
ShutdownOption is a mutator for shutdown options.
func OptDefaultShutdownSignal ¶ added in v1.20201204.1
func OptDefaultShutdownSignal() ShutdownOption
OptDefaultShutdownSignal returns an option that sets the shutdown signal to the defaults.
func OptShutdownSignal ¶ added in v1.20201204.1
func OptShutdownSignal(signal chan os.Signal) ShutdownOption
OptShutdownSignal sets the shutdown signal.
type ShutdownOptions ¶ added in v1.20201204.1
ShutdownOptions are the options for graceful shutdown.