refactor: move logger.Debug call to waitForShutdownSignal
ci/woodpecker/push/govulncheck Pipeline was successful Details
ci/woodpecker/push/test Pipeline was successful Details

This commit is contained in:
Dawid Wysokiński 2024-04-08 06:41:51 +02:00
parent 24b8ffd32c
commit 3fe539db19
Signed by: Kichiyaki
GPG Key ID: B5445E357FB8B892
3 changed files with 5 additions and 5 deletions

View File

@ -391,7 +391,7 @@ func runConsumer(c *cli.Context, name string, registerHandlers registerConsumerH
logger.Info("consumer is up and running", slog.String("name", name))
}
waitForShutdownSignal(ctx)
waitForShutdownSignal(ctx, logger)
if closeErr := router.Close(); closeErr != nil {
logger.Warn("couldn't close router", slog.Any("error", err))

View File

@ -175,9 +175,7 @@ var cmdServe = &cli.Command{
idleConnsClosed := make(chan struct{})
go func() {
waitForShutdownSignal(c.Context)
logger.Debug("received shutdown signal")
waitForShutdownSignal(c.Context, logger)
ctx, cancel := context.WithTimeout(c.Context, c.Duration(apiServerShutdownTimeoutFlag.Name))
defer cancel()

View File

@ -2,6 +2,7 @@ package main
import (
"context"
"log/slog"
"os"
"os/signal"
"syscall"
@ -15,8 +16,9 @@ func newShutdownSignalContext(parent context.Context) (context.Context, context.
return signal.NotifyContext(parent, shutdownSignals...)
}
func waitForShutdownSignal(ctx context.Context) {
func waitForShutdownSignal(ctx context.Context, logger *slog.Logger) {
ctx, cancel := newShutdownSignalContext(ctx)
defer cancel()
<-ctx.Done()
logger.Debug("received shutdown signal")
}