interrupt

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: Unlicense Imports: 9 Imported by: 0

README

interrupt

Handle shutdowns cleanly and enable hot reload

Documentation

Overview

Package interrupt is a library for providing handling for Ctrl-C/Interrupt handling and triggering callbacks for such things as closing files, flushing buffers, and other elements of graceful shutdowns.

Index

Constants

This section is empty.

Variables

View Source
var (
	// RestartRequested is set true after restart is requested.
	RestartRequested bool // = true

	// ShutdownRequestChan is a channel that can receive shutdown requests
	ShutdownRequestChan = qu.T()

	// HandlersDone is closed after all interrupt handlers run the first time an
	// interrupt is signaled.
	HandlersDone = make(qu.C)
)

Functions

func AddHandler

func AddHandler(handler func())

AddHandler adds a handler to call when a SIGINT (Ctrl+C) is received.

func GoroutineDump

func GoroutineDump() string

GoroutineDump returns a string with the current goroutine dump in order to show what's going on in case of timeout.

func Listener

func Listener()

Listener listens for interrupt signals, registers interrupt callbacks, and responds to custom shutdown signals as required

func Request

func Request()

Request programmatically requests a shutdown

func RequestRestart

func RequestRestart()

RequestRestart sets the reset flag and requests a restart

func Requested

func Requested() bool

Requested returns true if an interrupt has been requested

func Restart

func Restart()

Restart uses syscall.Exec to restart the process. macOS and Windows are not implemented, currently.

Types

type HandlerWithSource

type HandlerWithSource struct {
	Source string
	Fn     func()
}

HandlerWithSource is an interrupt handling closure and the source location that it was sent from.

Jump to

Keyboard shortcuts

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