diff options
author | Alan Pearce | 2024-06-26 18:47:22 +0200 |
---|---|---|
committer | Alan Pearce | 2024-06-26 18:47:22 +0200 |
commit | d6253aca4b4a00b4bcd2adb4004a63f56a692f74 (patch) | |
tree | 5c5d1178dc61275eb7f8958a405440958197a5d4 /internal/server | |
parent | 767caaab43143fd5e22bbea044f1aa83ebb13517 (diff) | |
download | website-d6253aca4b4a00b4bcd2adb4004a63f56a692f74.tar.lz website-d6253aca4b4a00b4bcd2adb4004a63f56a692f74.tar.zst website-d6253aca4b4a00b4bcd2adb4004a63f56a692f74.zip |
reorganise server startup
Diffstat (limited to 'internal/server')
-rw-r--r-- | internal/server/server.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/internal/server/server.go b/internal/server/server.go index 05b1d2a..9781364 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -109,6 +109,9 @@ func New(runtimeConfig *Config) (*Server, error) { 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 @@ func New(runtimeConfig *Config) (*Server, error) { Development: runtimeConfig.Development, } - if runtimeConfig.Development { - applyDevModeOverrides(config, listenAddress) + err = rebuild(builderConfig, config) + if err != nil { + return nil, err + } + if runtimeConfig.Development { liveReload := livereload.New() top.Handle("/_/reload", liveReload) liveReload.Start() @@ -152,11 +158,6 @@ func New(runtimeConfig *Config) (*Server, error) { }) } - err = rebuild(builderConfig, config) - if err != nil { - return nil, err - } - loggingMux := http.NewServeMux() mux, err := website.NewMux(config, runtimeConfig.Root) if err != nil { |