gracefulshutdown

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 6 Imported by: 0

README

gracefulshutdown

Go

gracefulshutdown is a Go library that allows applications to register shutdown handlers to be executed during server shutdown.

Usage

Register a shutdown handler:

gracefulshutdown.AddShutdownHandler(func() error {
    log.Println("Shutting down server")
    return httpServer.Shutdown(ctx)
})

See example/example.go for a full working example.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddShutdownHandler

func AddShutdownHandler(handler func() error)

AddShutdownHandler registers a handler to be run before shutdown.

func WaitForShutdown

func WaitForShutdown()

WaitForShutdown blocks on a channel that will never be closed. Its purpose is to be called by main to prevent server exit while shutdown handler goroutines are executing.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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