reorganise server startup
Alan Pearce alan@alanpearce.eu
Wed, 26 Jun 2024 18:47:22 +0200
1 files changed, 8 insertions(+), 7 deletions(-)
jump to
M internal/server/server.go → internal/server/server.go
@@ -109,6 +109,9 @@ config, err := cfg.GetConfig() if err != nil { return nil, errors.WithMessage(err, "error parsing configuration file") } + if runtimeConfig.Development { + applyDevModeOverrides(config, runtimeConfig.ListenAddress) + } listenAddress := net.JoinHostPort(runtimeConfig.ListenAddress, strconv.Itoa(runtimeConfig.Port)) top := http.NewServeMux() @@ -119,9 +122,12 @@ Destination: runtimeConfig.Root, Development: runtimeConfig.Development, } + err = rebuild(builderConfig, config) + if err != nil { + return nil, err + } + if runtimeConfig.Development { - applyDevModeOverrides(config, listenAddress) - liveReload := livereload.New() top.Handle("/_/reload", liveReload) liveReload.Start() @@ -150,11 +156,6 @@ if err != nil { log.Error("error rebuilding site", "error", err) } }) - } - - err = rebuild(builderConfig, config) - if err != nil { - return nil, err } loggingMux := http.NewServeMux()