Answer the question
In order to leave comments, you need to log in
Which Gracefull shutdown in Golang do you recommend?
Please share a good example of Gracefull shutdown in Golang.
Answer the question
In order to leave comments, you need to log in
// Graceful shutdown, пишем это перед последней ждущей функцией
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
<-c
// здесь логика завершения и очистки ресурсов, например:
db.Close()
app.Exit()
}()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question