shutdown

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package shutdown turns the first interrupt into a graceful stop and the second into an immediate exit.

Both akari binaries want the same behavior on Ctrl-C: acknowledge the request at once, let in-flight work wind down to a clean stopping point, then exit; and if the operator interrupts again, stop waiting and quit now. The context this package returns is cancelled on the first signal. It is meant for deciding whether to start new work, not for tearing down work already underway, so a single Ctrl-C lets the current unit finish: detach long-running calls with context.WithoutCancel and gate the loop on the returned context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Notify

func Notify(ack func()) (ctx context.Context, stop func())

Notify installs an interrupt handler and returns a context cancelled on the first SIGINT or SIGTERM. ack runs once, just before the cancel, so the caller can log that shutdown has begun the instant the signal lands. A second signal exits the process with status 130 instead of waiting for graceful cleanup.

The returned stop unregisters the handler and cancels the context; defer it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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