Alter graceful shutdown to be compatible with Docker
This commit is contained in:
parent
8fcde54067
commit
a24a333e4a
2 changed files with 4 additions and 8 deletions
4
main.go
4
main.go
|
@ -38,7 +38,7 @@ func run() error {
|
|||
platform.StartCron()
|
||||
|
||||
shutdownSig := make(chan os.Signal)
|
||||
signal.Notify(shutdownSig, syscall.SIGINT)
|
||||
signal.Notify(shutdownSig, syscall.SIGINT, syscall.SIGTERM)
|
||||
wg := new(sync.WaitGroup)
|
||||
|
||||
httpServer := platform.NewServer(conf.HTTP.Address())
|
||||
|
@ -52,7 +52,7 @@ func run() error {
|
|||
|
||||
platform.StopCron()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
|
||||
defer cancel()
|
||||
if err := httpServer.Shutdown(ctx); err != nil {
|
||||
slog.Error("http server did not shutdown correctly", "error", err)
|
||||
|
|
|
@ -45,12 +45,8 @@ func init() {
|
|||
|
||||
func NewServer(address string) *http.Server {
|
||||
return &http.Server{
|
||||
Addr: address,
|
||||
Handler: http.HandlerFunc(handler),
|
||||
ReadTimeout: 10,
|
||||
ReadHeaderTimeout: 10,
|
||||
WriteTimeout: 10,
|
||||
IdleTimeout: 10,
|
||||
Addr: address,
|
||||
Handler: http.HandlerFunc(handler),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue