graceful

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvWorker       = "GRACEFUL_WORKER"
	EnvNumFD        = "GRACEFUL_NUMFD"
	EnvOldWorkerPid = "GRACEFUL_OLD_WORKER_PID"
	ValWorker       = "1"
)

constants

Variables

View Source
var (
	ErrNoServers = errors.New("no servers")
)
View Source
var (
	StartedAt time.Time
)

Functions

func IsMaster

func IsMaster() bool

func IsWorker

func IsWorker() bool

func ListenAndServe

func ListenAndServe(addr string, handler http.Handler) error

ListenAndServe starts server with (addr, handler)

Types

type Option

type Option func(o *option)

func WithReloadSignals

func WithReloadSignals(sigs []syscall.Signal) Option

WithReloadSignals set reload signals, otherwise, default ones are used

func WithStopSignals

func WithStopSignals(sigs []syscall.Signal) Option

WithStopSignals set stop signals, otherwise, default ones are used

func WithStopTimeout

func WithStopTimeout(timeout time.Duration) Option

WithStopTimeout set stop timeout for graceful shutdown

if timeout occurs, running connections will be discard violently.

func WithWatchInterval

func WithWatchInterval(timeout time.Duration) Option

WithWatchInterval set watch interval for worker checking master process state

type Server

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

func NewServer

func NewServer(opts ...Option) *Server

func (*Server) Register

func (s *Server) Register(addr string, handler http.Handler)

Register an addr and its corresponding handler all (addr, handler) pair will be started with server.Run

func (*Server) RegisterUnix

func (s *Server) RegisterUnix(addr string, handler http.Handler)

RegisterUnix register (addr, handler) on unix socket

func (*Server) Reload

func (s *Server) Reload() error

Reload reload server gracefully

func (*Server) Run

func (s *Server) Run() error

Run runs all register servers

Jump to

Keyboard shortcuts

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