Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cmd/serve): add in default-shutdown-timeout flag to increase shutdown timeout on http server shutdown #1162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my view this should go into the config file instead

}
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
Loading