Отвязать жизненный цикл сервера от сборки приложения

This commit is contained in:
2026-10-06 14:50:12 +03:00
parent 6720108793
commit 46c00436a0
3 changed files with 28 additions and 12 deletions
+2 -1
View File
@@ -33,7 +33,8 @@ func main() {
defer stop()
log.Info("starting", "env", cfg.Env, "addr", cfg.Addr(), "shutdown_timeout", cfg.ShutdownTimeout.String())
if err := server.Run(ctx, log, ln, app.New(log, cfg.MaxBodyBytes), cfg.ShutdownTimeout); err != nil {
a := app.New(log, cfg.MaxBodyBytes)
if err := server.Run(ctx, log, ln, a.Engine, a.Health, cfg.ShutdownTimeout); err != nil {
log.Error("server stopped with error", "error", err.Error())
os.Exit(1)
}