15 lines
421 B
Go
15 lines
421 B
Go
package platform
|
|
|
|
import (
|
|
"context"
|
|
"os/signal"
|
|
)
|
|
|
|
// SignalContext returns a context canceled when an interactive termination
|
|
// signal arrives: Ctrl+C on every OS, plus SIGTERM on Unix. It is the single
|
|
// graceful-shutdown hook for the whole process.
|
|
func SignalContext() (context.Context, context.CancelFunc) {
|
|
ctx, cancel := signal.NotifyContext(context.Background(), shutdownSignals()...)
|
|
return ctx, cancel
|
|
}
|