grace

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SignalDefault specify exception signals for application.
	// Program will want exit when catch SIGINT/SIGTERM and SIGHUP is ignored
	// since that is usually used for triggering a reload of configuration which
	// isn't  supported but shouldn't kill the process either.
	SignalDefault = []os.Signal{os.Interrupt, syscall.SIGTERM, syscall.SIGHUP}
)

Functions

func Exit

func Exit(code int)

Exit terminates the application via os.Exit but waits for all exit handlers to complete before calling os.Exit.

func Fatal

func Fatal(v ...interface{})

Fatal is a replacement for log.Fatal which will trigger the closure of all registered exit handlers and waits for their completion and then call os.Exit(1).

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf is a replacement for log.Fatalf and behaves like Fatal.

func Listen

func Listen(fn SignalFun, signals ...os.Signal)

Listen registers an signal handler which is called on os.Signal catch or when Exit/Fatal/Fatalf is called. if signals is empty will use SignalExceptions as signals.

func Wait

func Wait()

Wait waits for all exit handlers to complete.

Types

type SignalFun

type SignalFun func(os.Signal) (isContinue bool)

SignalFun os.Signal handler

Jump to

Keyboard shortcuts

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