grace

package
v2.19.4 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetProcessFromFile

func GetProcessFromFile(pfile string) (*os.Process, error)

GetProcessFromFile reads the pidfile and returns the running process or error if the process or file are not available.

Types

type Option

type Option func(w *Watcher)

Option represent an option.

func WithGracefuleShutdownTimeout added in v2.16.0

func WithGracefuleShutdownTimeout(seconds int) Option

func WithLogger

func WithLogger(l zerolog.Logger) Option

WithLogger adds a logger to the Watcher.

func WithPIDFile

func WithPIDFile(fn string) Option

WithPIDFile specifies the pid file to use.

type Server

type Server interface {
	Stop() error
	GracefulStop() error
	Network() string
	Address() string
}

Server is the interface that servers like HTTP or gRPC servers need to implement.

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher watches a process for a graceful restart preserving open network sockets to avoid packet loss.

func NewWatcher

func NewWatcher(opts ...Option) *Watcher

NewWatcher creates a Watcher.

func (*Watcher) Exit

func (w *Watcher) Exit(errc int)

Exit exits the current process cleaning up existing pid files.

func (*Watcher) GetListeners

func (w *Watcher) GetListeners(servers map[string]Server) (map[string]net.Listener, error)

GetListeners return grpc listener first and http listener second.

func (*Watcher) TrapSignals

func (w *Watcher) TrapSignals()

TrapSignals captures the OS signal.

func (*Watcher) WritePID

func (w *Watcher) WritePID() error

WritePID writes the pid to the configured pid file.

Jump to

Keyboard shortcuts

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