This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/internal/common/global.go
Jens Langhammer 9e1a518689 internal: add signal handler for SIGTERM
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
2022-05-08 23:05:47 +02:00

26 lines
427 B
Go

package common
import (
"math/rand"
"os"
"os/signal"
"syscall"
"time"
"github.com/getsentry/sentry-go"
)
func Init() chan os.Signal {
rand.Seed(time.Now().UnixNano())
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)
signal.Notify(interrupt, syscall.SIGINT)
signal.Notify(interrupt, syscall.SIGTERM)
return interrupt
}
func Defer() {
sentry.Flush(time.Second * 5)
sentry.Recover()
}