all repos — homestead @ 0296be4cbce9b13896dd703e868029672e55fd8c

Code for my website

shorten shutdown timeout in development

Alan Pearce
commit

0296be4cbce9b13896dd703e868029672e55fd8c

parent

a0c252e397bf83beada99ad28fc87c7acae34ef0

2 files changed, 7 insertions(+), 4 deletions(-)

changed files
M internal/server/server.gointernal/server/server.go
@@ -24,9 +24,10 @@ IdleTimeout = 10 * time.Minute
) type Options struct { - Redirect bool `conf:"default:true"` - ListenAddress string `conf:"default:::"` - Port int `conf:"default:8080,short:p"` + Redirect bool `conf:"default:true"` + ListenAddress string `conf:"default:::"` + Port int `conf:"default:8080,short:p"` + ShutdownTimeout time.Duration `conf:"default:10s"` Development bool `conf:"-"` LiveReload *livereload.LiveReload `conf:"-"`
@@ -122,7 +123,7 @@ idleConnsClosed := make(chan struct{})
go func() { s.log.Debug("shutting down server") - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), s.options.ShutdownTimeout) defer cancel() err := s.server.Shutdown(ctx) s.log.Debug("server shut down")
M main.gomain.go
@@ -5,6 +5,7 @@ "context"
"fmt" "os" "os/signal" + "time" "go.alanpearce.eu/homestead/internal/server" "go.alanpearce.eu/homestead/internal/website"
@@ -35,6 +36,7 @@
if options.Website.Development { livereload := livereload.New() options.Server.LiveReload = livereload + options.Server.ShutdownTimeout = 100 * time.Millisecond options.Website.LiveReload = livereload options.Server.Development = true }