Skip to content

Commit

Permalink
feat(cmd/serve): add in default-shutdown-timeout flag to increase shu…
Browse files Browse the repository at this point in the history
…tdown timeout on http server shutdown
  • Loading branch information
ottingbob committed Apr 29, 2024
1 parent f6adf0b commit 2d97c76
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ func init() {

serveCmd.PersistentFlags().Bool("disable-telemetry", false, "Disable anonymized telemetry reports - for more information please visit https://www.ory.sh/docs/ecosystem/sqa")
serveCmd.PersistentFlags().Bool("sqa-opt-out", false, "Disable anonymized telemetry reports - for more information please visit https://www.ory.sh/docs/ecosystem/sqa")
serveCmd.PersistentFlags().Int("default-shutdown-timeout", 5, "Set the default shutdown timeout in seconds for server shutdown when trapping SIGTERM and SIGINT")
}
7 changes: 7 additions & 0 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ func RunServe(version, build, date string) func(cmd *cobra.Command, args []strin
adminmw.Use(telemetry)
publicmw.Use(telemetry)

// Override the `graceful.DefaultShutdownTimeout` value
graceful.DefaultShutdownTimeout = 5 * time.Second
defaultShutdownTimeout, _ := cmd.Flags().GetInt("default-shutdown-timeout")
if defaultShutdownTimeout > 0 {
graceful.DefaultShutdownTimeout = time.Duration(defaultShutdownTimeout) * time.Second
}

prometheusRepo := metrics.NewConfigurablePrometheusRepository(d, logger)
var wg sync.WaitGroup
tasks := []func(){
Expand Down

0 comments on commit 2d97c76

Please sign in to comment.