signal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0, BSD-3-Clause, MIT Imports: 8 Imported by: 0

Documentation

Overview

Package signal provides cross-platform signal handling for graceful shutdown. Per AI.md PART 7: Signal handling must be platform-dependent with build tags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsShuttingDown

func IsShuttingDown() bool

IsShuttingDown returns true if graceful shutdown is in progress

func KillProcess

func KillProcess(pid int, graceful bool) error

KillProcess sends signal to process (Unix) Per AI.md PART 7: killProcess helper

func Setup

func Setup(cfg ShutdownConfig)

Setup configures signal handling with the given config This is the main entry point - it calls the platform-specific setupSignals

Types

type ShutdownConfig

type ShutdownConfig struct {
	// Server is the HTTP server to shut down (optional if ShutdownFunc is provided)
	Server *http.Server
	// ShutdownFunc is called to perform shutdown (alternative to Server)
	// If provided, this is called instead of Server.Shutdown
	ShutdownFunc    func(ctx context.Context) error
	PIDFile         string
	InFlightTimeout time.Duration // Default: 30s
	ChildTimeout    time.Duration // Default: 10s
	DatabaseTimeout time.Duration // Default: 5s
	LogFlushTimeout time.Duration // Default: 2s
	OnReopenLogs    func()        // Called on SIGUSR1 (Unix only)
	OnDumpStatus    func()        // Called on SIGUSR2 (Unix only)
	OnCloseDatabase func()        // Called during shutdown
	OnFlushLogs     func()        // Called during shutdown
	GetChildPIDs    func() []int  // Returns child process PIDs
}

ShutdownConfig holds configuration for graceful shutdown

Jump to

Keyboard shortcuts

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