all repos — website @ d6253aca4b4a00b4bcd2adb4004a63f56a692f74

My website

reorganise server startup
Alan Pearce alan@alanpearce.eu
Wed, 26 Jun 2024 18:47:22 +0200
commit

d6253aca4b4a00b4bcd2adb4004a63f56a692f74

parent

767caaab43143fd5e22bbea044f1aa83ebb13517

1 files changed, 8 insertions(+), 7 deletions(-)

jump to
M internal/server/server.gointernal/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()