// Package app provides application lifecycle primitives. package app import ( "context" "os" "os/signal" "syscall" ) // NewContext returns a context for the whole application lifecycle. // // The context is cancelled when the parent is cancelled or when the process // receives an interrupt or a termination signal. Call the returned function // during shutdown to unregister signal notifications and release resources. func NewContext(parent context.Context) (context.Context, context.CancelFunc) { return signal.NotifyContext(parent, os.Interrupt, syscall.SIGTERM) }