shutdown

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0, BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppSelfShutdownCaller

func AppSelfShutdownCaller(handler interface{}, params ...interface{})

AppSelfShutdownCaller is used to signal a app self shutdown caused by an error.

func WithSelfShutdownLogsEnabled

func WithSelfShutdownLogsEnabled(selfShutdownLogsEnabled bool) options.Option[ShutdownHandler]

WithSelfShutdownLogsEnabled defines whether to store self-shutdown events to a log file.

func WithSelfShutdownLogsFilePath

func WithSelfShutdownLogsFilePath(selfShutdownLogsFilePath string) options.Option[ShutdownHandler]

WithSelfShutdownLogsFilePath defines the file path to the self-shutdown log.

func WithStopGracePeriod

func WithStopGracePeriod(stopGracePeriod time.Duration) options.Option[ShutdownHandler]

WithStopGracePeriod defines the the maximum time to wait for background processes to finish during shutdown before terminating the app.

Types

type Events

type Events struct {
	// Fired when a app self shutdown was caused by an error.
	AppSelfShutdown *event.Event2[string, bool]
	// Fired when a clean shutdown was requested.
	AppShutdown *event.Event
}

Events holds Shutdown related events.

type ShutdownHandler

type ShutdownHandler struct {
	// the logger used to log events.
	*logger.WrappedLogger

	// Events are the events that are triggered by the ShutdownHandler.
	Events *Events
	// contains filtered or unexported fields
}

ShutdownHandler waits until a shutdown signal was received or the app tried to shutdown itself, and shuts down all processes gracefully.

func NewShutdownHandler

func NewShutdownHandler(log *logger.Logger, daemon daemon.Daemon, opts ...options.Option[ShutdownHandler]) *ShutdownHandler

NewShutdownHandler creates a new shutdown handler.

func (*ShutdownHandler) Run

func (gs *ShutdownHandler) Run() error

Run starts the ShutdownHandler go routine.

func (*ShutdownHandler) SelfShutdown

func (gs *ShutdownHandler) SelfShutdown(msg string, critical bool)

SelfShutdown can be called in order to instruct the app to shutdown cleanly without receiving any interrupt signals.

Jump to

Keyboard shortcuts

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