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.
2021-06-16 15:29:01 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
2022-05-08 21:05:47 +00:00
|
|
|
"syscall"
|
2021-06-16 15:29:01 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/getsentry/sentry-go"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Init() chan os.Signal {
|
|
|
|
interrupt := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(interrupt, os.Interrupt)
|
2022-05-08 21:05:47 +00:00
|
|
|
signal.Notify(interrupt, syscall.SIGINT)
|
|
|
|
signal.Notify(interrupt, syscall.SIGTERM)
|
2021-06-16 15:29:01 +00:00
|
|
|
return interrupt
|
|
|
|
}
|
|
|
|
|
|
|
|
func Defer() {
|
2021-07-29 09:30:30 +00:00
|
|
|
sentry.Flush(time.Second * 5)
|
|
|
|
sentry.Recover()
|
2021-06-16 15:29:01 +00:00
|
|
|
}
|