server

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package server runs a Fiber app with signal-based graceful shutdown.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunGraceful

func RunGraceful(app *fiber.App, addr string, timeout time.Duration,
	cleanup ...func(ctx context.Context) error) error

RunGraceful starts app and blocks until SIGINT/SIGTERM (or a listen error), then shuts the server down within timeout and runs the cleanup hooks in order.

func RunGracefulWithConfig added in v1.2.0

func RunGracefulWithConfig(app *fiber.App, addr string, cfg Config) error

RunGracefulWithConfig is RunGraceful with pre-shutdown hooks and a drain delay. See Config for the shutdown ordering.

Types

type Config added in v1.2.0

type Config struct {
	Timeout     time.Duration
	DrainDelay  time.Duration
	PreShutdown []func(ctx context.Context) error
	Cleanup     []func(ctx context.Context) error
}

Config tunes graceful shutdown. Timeout bounds the whole shutdown sequence (default 10s when zero or negative). PreShutdown hooks run before the server stops accepting connections (e.g. to flip a readiness gate); DrainDelay then waits so a load balancer can stop routing before in-flight connections are closed; Cleanup hooks run after the server has shut down.

Jump to

Keyboard shortcuts

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