Small fixes
* Shut down the web server first to prevent errors caused by clients trying to use functionality that has already been shut down, causing errors and potentially delaying the shutdown process. * remove write timeout from the websocket Write() function. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
5a26614acf
commit
86a0b0cf4f
2 changed files with 13 additions and 19 deletions
|
|
@ -372,6 +372,13 @@ func main() {
|
|||
|
||||
<-ctx.Done()
|
||||
|
||||
slog.InfoContext(ctx, "shutting down http server")
|
||||
shutdownCtx, shutdownCancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||
defer shutdownCancel()
|
||||
if err := srv.Shutdown(shutdownCtx); err != nil {
|
||||
slog.With(slog.Any("error", err)).ErrorContext(ctx, "graceful api server shutdown failed")
|
||||
}
|
||||
|
||||
if err := cacheWorker.Stop(); err != nil {
|
||||
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to stop credentials worker")
|
||||
}
|
||||
|
|
@ -386,13 +393,6 @@ func main() {
|
|||
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to stop provider worker")
|
||||
}
|
||||
|
||||
slog.InfoContext(ctx, "shutting down http server")
|
||||
shutdownCtx, shutdownCancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||
defer shutdownCancel()
|
||||
if err := srv.Shutdown(shutdownCtx); err != nil {
|
||||
slog.With(slog.Any("error", err)).ErrorContext(ctx, "graceful api server shutdown failed")
|
||||
}
|
||||
|
||||
slog.With(slog.Any("error", err)).InfoContext(ctx, "waiting for runner to stop")
|
||||
if err := runner.Wait(); err != nil {
|
||||
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to shutdown workers")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue