graceful

package
v7.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2020 License: MIT Imports: 13 Imported by: 0

README

Graceful

Default settings

SIGINT and SIGTERM are stopping the application SIGHUB is gracefully restarting it.

Graceful shutdown:

  • 1 minute to finish requests
  • Then connections cut

Graceful restart:

  • Socket file descriptor given to fork/exec child
  • 30 minutes to finish requests for old process (can switch to shutdown with a SIGINT/SIGTERM on this process)

Usage

graceful.NewService()

Configuration with options

s := graceful.NewService(
	graceful.WithWaitDuration(30 * time.Second),
	graceful.WithReloadWaitDuration(time.Hour),
	graceful.WithPIDFile("/var/run/service.pid"),
)

err := s.ListenAndServe(ctx, "tcp", ":9000", handler)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewService

func NewService(opts ...Option) *service

Types

type Option

type Option func(*service)

func WithPIDFile

func WithPIDFile(path string) Option

func WithReloadWaitDuration

func WithReloadWaitDuration(d time.Duration) Option

func WithWaitDuration

func WithWaitDuration(d time.Duration) Option

Directories

Path Synopsis
test-fixtures

Jump to

Keyboard shortcuts

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