all repos — searchix @ 49e3004d33bf84aa081460e4a6d89a8d84cc12b0

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: shorten shutdown timeout in development

Alan Pearce
commit

49e3004d33bf84aa081460e4a6d89a8d84cc12b0

parent

c0c02ac768a144f4417edfba967a4f7857a150b9

1 file changed, 6 insertions(+), 1 deletion(-)

jump to
M internal/server/server.gointernal/server/server.go
@@ -16,6 +16,8 @@ "golang.org/x/net/http2"
"golang.org/x/net/http2/h2c" ) +var shutdownTimeout = 10 * time.Second + type Server struct { cfg *config.Config log *log.Logger
@@ -81,10 +83,13 @@ func (s *Server) Stop() chan struct{} {
s.log.Debug("stop called") idleConnsClosed := make(chan struct{}) + if s.cfg.Web.Environment == "development" { + shutdownTimeout = 1 * time.Second + } go func() { s.log.Debug("shutting down server") - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout) defer cancel() err := s.server.Shutdown(ctx) s.log.Debug("server shut down")