Documentation ¶
Overview ¶
Package graceful contains tools for graceful shutdown. GS refers to the process of shutting down a system in a controlled manner, allowing it to complete ongoing tasks, release resources, and perform necessary cleanup operations before terminating. This ensures that the system stops functioning without causing data loss, corruption, or other issues.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultProcess = New(15*time.Second, log.Logger, NewSigChan(syscall.SIGINT, syscall.SIGTERM))
DefaultProcess is a process instance with some sane defaults.
Functions ¶
func AddService ¶
func AddStopper ¶
func AddStopper(fn func())
func NewSigChan ¶
NewSigChan creates a new signal channel.
func ShutdownNow ¶
func ShutdownNow()
func WaitForShutdown ¶
func WaitForShutdown()
Types ¶
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process represents "virtual" process that contains routines that can be started and stopped Note that ANY failure in starting a service will cause the process to shutdown
func (*Process) AddService ¶
AddService adds Service to the process.
func (*Process) AddStarter ¶
AddStarter runs a function that starts something. This is a blocking call for blocking .Start() services
func (*Process) AddStopper ¶
func (p *Process) AddStopper(fn func())
AddStopper adds a function will be executed during shutdown.
func (*Process) ShutdownNow ¶
func (p *Process) ShutdownNow()
ShutdownNow invokes shutdown of all services.
func (*Process) WaitForShutdown ¶
func (p *Process) WaitForShutdown()
WaitForShutdown blocks current routine until a shutdown signal is received