From de371454715160304264142b994de336b409fa30 Mon Sep 17 00:00:00 2001 From: Simon Martens Date: Tue, 27 Jan 2026 18:39:22 +0100 Subject: [PATCH] +FIX: add option to disable watchers even in dev mode --- app/config.go | 7 +++++++ app/pb.go | 4 ++-- config.dev.json | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/config.go b/app/config.go index 85c1007..a70f624 100644 --- a/app/config.go +++ b/app/config.go @@ -29,6 +29,7 @@ type Config struct { // At least one of these should be set Debug bool `json:"debug,omitempty" envconfig:"DEBUG"` AllowTestLogin bool `json:"allow_test_login,omitempty" envconfig:"ALLOW_TEST_LOGIN"` + DisableWatchers bool `json:"disable_watchers,omitempty" envconfig:"DISABLE_WATCHERS"` } func NewConfigProvider(files []string, devfiles []string) *ConfigProvider { @@ -71,6 +72,12 @@ func (c *ConfigProvider) Validate() error { slog.Info("Debug mode is disabled") } + if c.DisableWatchers { + slog.Info("Template watchers are disabled") + } else { + slog.Info("Template watchers are enabled") + } + return nil } diff --git a/app/pb.go b/app/pb.go index 9b5ee80..c7205ff 100644 --- a/app/pb.go +++ b/app/pb.go @@ -184,8 +184,9 @@ func (app *App) Serve() error { panic(err) } - if app.MAConfig.Debug { + if app.MAConfig.Debug && !app.MAConfig.DisableWatchers { app.setWatchers(engine) + engine.Debug() } // INFO: we use OnServe, but here is also OnBootstrap @@ -686,7 +687,6 @@ func (app *App) setWatchers(engine *templating.Engine) { } else { watcher.AddRecursive(LAYOUT_DIR) watcher.AddRecursive(ROUTES_DIR) - engine.Debug() rwatcher, err := RefreshWatcher(engine) if err != nil { app.PB.Logger().Error("Failed to create watcher, continuing without", "error", err) diff --git a/config.dev.json b/config.dev.json index 8e2cfdf..1923909 100644 --- a/config.dev.json +++ b/config.dev.json @@ -1,4 +1,5 @@ { "debug": true, - "allow_test_login": true + "allow_test_login": true, + "disable_watchers": false }