graceful

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 12 Imported by: 2

README

Package graceful v1.1.1

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

Jump to

Keyboard shortcuts

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