FILE / ScuroNeko/est
internal/app/context.go
Исходный файл и его история в репозитории.
19 lines
577 B
Go
19 lines
577 B
Go
// 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)
|
|
}
|