Skip to content

Commit

Permalink
Graceful api server shutdown tweaks (#4)
Browse files Browse the repository at this point in the history
* more attempts to gracefully shut down

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* fix import order

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

---------

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
  • Loading branch information
crenshaw-dev authored Jun 13, 2024
1 parent 7fde5eb commit 3eb12d7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
2 changes: 2 additions & 0 deletions cmd/argocd-server/commands/argocd_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ func NewCommand() *cobra.Command {
if closer != nil {
closer()
}
log.Info("API Server successfully shut down.")
break
}
},
}
Expand Down
34 changes: 19 additions & 15 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,15 +585,17 @@ func (a *ArgoCDServer) Run(ctx context.Context, listeners *Listeners) {
}
}()

// Shutdown https server
wg.Add(1)
go func() {
defer wg.Done()
err := httpsS.Shutdown(sCtx)
if err != nil {
log.Errorf("Error shutting down https server: %s", err)
}
}()
if httpsS != nil {
// Shutdown https server
wg.Add(1)
go func() {
defer wg.Done()
err := httpsS.Shutdown(sCtx)
if err != nil {
log.Errorf("Error shutting down https server: %s", err)
}
}()
}

// Shutdown gRPC server
wg.Add(1)
Expand All @@ -612,12 +614,14 @@ func (a *ArgoCDServer) Run(ctx context.Context, listeners *Listeners) {
}
}()

// Shutdown tls server
wg.Add(1)
go func() {
defer wg.Done()
tlsm.Close()
}()
if tlsm != nil {
// Shutdown tls server
wg.Add(1)
go func() {
defer wg.Done()
tlsm.Close()
}()
}

// Shutdown tcp server
wg.Add(1)
Expand Down

0 comments on commit 3eb12d7

Please sign in to comment.