Skip to content

Commit

Permalink
Increase shutdown timeout to 5 minutes (#4195)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnr committed Apr 28, 2023
1 parent d94444d commit 625f6d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions temporal/fx.go
Expand Up @@ -28,7 +28,6 @@ import (
"context"
"fmt"
"strings"
"time"

"github.com/pborman/uuid"
"go.opentelemetry.io/otel"
Expand Down Expand Up @@ -285,17 +284,17 @@ func (s ServerFx) Stop() error {

func StopService(logger log.Logger, app *fx.App, svcName primitives.ServiceName, stopChan chan struct{}) {
stopCtx, cancelFunc := context.WithTimeout(context.Background(), serviceStopTimeout)
defer cancelFunc()
err := app.Stop(stopCtx)
cancelFunc()
if err != nil {
logger.Error("Failed to stop service", tag.Service(svcName), tag.Error(err))
}

// verify "Start" goroutine returned
select {
case <-stopChan:
case <-time.After(time.Minute):
logger.Error("Timed out (1 minute) waiting for service to stop.", tag.Service(svcName))
case <-stopCtx.Done():
logger.Error("Timed out waiting for service to stop", tag.Service(svcName), tag.NewDurationTag("timeout", serviceStopTimeout))
}
}

Expand Down
2 changes: 1 addition & 1 deletion temporal/server.go
Expand Up @@ -33,7 +33,7 @@ import (
const (
mismatchLogMessage = "Supplied configuration key/value mismatches persisted cluster metadata. Continuing with the persisted value as this value cannot be changed once initialized."
serviceStartTimeout = time.Duration(15) * time.Second
serviceStopTimeout = time.Duration(60) * time.Second
serviceStopTimeout = time.Duration(5) * time.Minute
)

type (
Expand Down

0 comments on commit 625f6d2

Please sign in to comment.