package graceful_shutdown import ( "git.rinsvent.ru/rinsvent/gol" "go.uber.org/zap" "os" "os/signal" "syscall" ) type FuncShutdowner struct{} func (sh *FuncShutdowner) Wait(f func()) { sigChan := make(chan os.Signal, 2) signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) sig := <-sigChan gol.With(zap.String("sig", sig.String())).Info("Gracefully shutting down") f() } func NewFuncShutdowner() FuncShutdowner { return FuncShutdowner{} }