Исправить замечания ревью: защита rollout от остановленных реплик, чтение серий, время экспериментов по часам Docker, выход сервера при ошибке старта
This commit is contained in:
+13
-6
@@ -80,15 +80,22 @@ func run(ctx context.Context, log *slog.Logger, cfg config.Config, alias string)
|
||||
InstanceID: alias,
|
||||
IdempotencyTTL: cfg.IdempotencyTTL,
|
||||
})
|
||||
var background sync.WaitGroup
|
||||
defer background.Wait() // before the deferred pool.Close
|
||||
background.Go(func() { chat.RunKeyCleanup(ctx, log, a.Chats, keyCleanupEvery) })
|
||||
var debugLn net.Listener
|
||||
if cfg.DebugAddr != "" {
|
||||
publishDebugVars(alias, pool)
|
||||
debugLn, err := net.Listen("tcp", cfg.DebugAddr)
|
||||
if err != nil {
|
||||
if debugLn, err = net.Listen("tcp", cfg.DebugAddr); err != nil {
|
||||
return fmt.Errorf("listen on %s: %w", cfg.DebugAddr, err)
|
||||
}
|
||||
publishDebugVars(alias, pool)
|
||||
}
|
||||
|
||||
// The background work ends with the server: on a signal, and also when
|
||||
// the server fails, so the deferred Wait cannot block the exit.
|
||||
var background sync.WaitGroup
|
||||
defer background.Wait() // before the deferred pool.Close
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel() // before Wait
|
||||
background.Go(func() { chat.RunKeyCleanup(ctx, log, a.Chats, keyCleanupEvery) })
|
||||
if debugLn != nil {
|
||||
background.Go(func() {
|
||||
if err := server.RunDebug(ctx, log, debugLn, expvar.Handler()); err != nil {
|
||||
log.Error("debug listener stopped", "error", err.Error())
|
||||
|
||||
Reference in New Issue
Block a user