Documentation ¶
Index ¶
- Constants
- Variables
- func GetChs() (stopCh, doneCh chan struct{})
- func HandleSignalCaughtEvent() bool
- func IsRunningInDemonizedMode() bool
- func QuitSignal() chan os.Signal
- func SendHUP(process *os.Process) error
- func SendKILL(process *os.Process) error
- func SendNilSig(process *os.Process) error
- func SendQUIT(process *os.Process) error
- func SendTERM(process *os.Process) error
- func SendUSR1(process *os.Process) error
- func SendUSR2(process *os.Process) error
- func ServeSignals() (err error)
- func SetHotReloadSignals(sig func() []os.Signal)
- func SetOnGetListener(fn func() net.Listener)
- func SetReloadSignals(sig func() []os.Signal)
- func SetSigEmtSignals(sig func() []os.Signal)
- func SetSigHandler(handler SignalHandlerFunc, signals ...os.Signal)
- func SetTermSignals(sig func() []os.Signal)
- type SignalHandlerFunc
Constants ¶
const (
// ErrnoForkAndDaemonFailed is os errno when daemon plugin and its impl occurs errors.
ErrnoForkAndDaemonFailed = -1
)
Variables ¶
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 ¶
QuitSignal return a channel for quit signal raising up.
func ServeSignals ¶
func ServeSignals() (err error)
ServeSignals calls handlers for system signals. before invoking ServeSignals(), you should run SetupSignals() at first.
func SetHotReloadSignals ¶
SetHotReloadSignals allows an functor to provide a list of Signals
func SetOnGetListener ¶
SetOnGetListener returns tcp/http listener for daemon hot-restarting
func SetReloadSignals ¶
SetReloadSignals allows an functor to provide a list of Signals
func SetSigEmtSignals ¶
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 ¶
SetTermSignals allows an functor to provide a list of Signals
Types ¶
type SignalHandlerFunc ¶
SignalHandlerFunc is the interface for signal handler functions.