sig

package
v1.8.6-p1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ErrnoForkAndDaemonFailed is os errno when daemon plugin and its impl occurs errors.
	ErrnoForkAndDaemonFailed = -1
)

Variables

View Source
var (
	// ErrStop should be returned signal handler function
	// for termination of handling signals.
	ErrStop = errors.New("stop serve signals")
)

Functions

func GetChs

func GetChs() (stopCh, doneCh chan struct{})

GetChs returns the standard `stop`, `done` channel

func HandleSignalCaughtEvent

func HandleSignalCaughtEvent() bool

HandleSignalCaughtEvent is a shortcut to block the main business logic loop but break it if os signals caught. `stop` channel will be trigger if any hooked os signal caught, such as os.Interrupt; the main business logic loop should trigger `done` once `stop` holds.

func IsRunningInDemonizedMode

func IsRunningInDemonizedMode() bool

IsRunningInDemonizedMode returns true if you are running under demonized mode. false means that you're running in normal console/tty mode.

func QuitSignal

func QuitSignal() chan os.Signal

QuitSignal return a channel for quit signal raising up.

func SendHUP

func SendHUP(process *os.Process) error

SendHUP sends the POSIX HUP signal

func SendKILL

func SendKILL(process *os.Process) error

SendKILL sends the POSIX KILL signal

func SendNilSig

func SendNilSig(process *os.Process) error

SendNilSig sends the POSIX NUL signal

func SendQUIT

func SendQUIT(process *os.Process) error

SendQUIT sends the POSIX QUIT signal

func SendTERM

func SendTERM(process *os.Process) error

SendTERM sends the POSIX TERM signal

func SendUSR1

func SendUSR1(process *os.Process) error

SendUSR1 sends the POSIX USR1 signal

func SendUSR2

func SendUSR2(process *os.Process) error

SendUSR2 sends the POSIX USR2 signal

func ServeSignals

func ServeSignals() (err error)

ServeSignals calls handlers for system signals. before invoking ServeSignals(), you should run SetupSignals() at first.

func SetHotReloadSignals

func SetHotReloadSignals(sig func() []os.Signal)

SetHotReloadSignals allows an functor to provide a list of Signals

func SetOnGetListener

func SetOnGetListener(fn func() net.Listener)

SetOnGetListener returns tcp/http listener for daemon hot-restarting

func SetReloadSignals

func SetReloadSignals(sig func() []os.Signal)

SetReloadSignals allows an functor to provide a list of Signals

func SetSigEmtSignals

func SetSigEmtSignals(sig func() []os.Signal)

SetSigEmtSignals allows an functor to provide a list of Signals

func SetSigHandler

func SetSigHandler(handler SignalHandlerFunc, signals ...os.Signal)

SetSigHandler sets handler for the given signals. SIGTERM has the default handler, he returns ErrStop.

func SetTermSignals

func SetTermSignals(sig func() []os.Signal)

SetTermSignals allows an functor to provide a list of Signals

Types

type SignalHandlerFunc

type SignalHandlerFunc func(sig os.Signal) (err error)

SignalHandlerFunc is the interface for signal handler functions.

Jump to

Keyboard shortcuts

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