mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2026-02-04 02:25:30 +00:00
+FIX: add option to disable watchers even in dev mode
This commit is contained in:
@@ -29,6 +29,7 @@ type Config struct {
|
|||||||
// At least one of these should be set
|
// At least one of these should be set
|
||||||
Debug bool `json:"debug,omitempty" envconfig:"DEBUG"`
|
Debug bool `json:"debug,omitempty" envconfig:"DEBUG"`
|
||||||
AllowTestLogin bool `json:"allow_test_login,omitempty" envconfig:"ALLOW_TEST_LOGIN"`
|
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 {
|
func NewConfigProvider(files []string, devfiles []string) *ConfigProvider {
|
||||||
@@ -71,6 +72,12 @@ func (c *ConfigProvider) Validate() error {
|
|||||||
slog.Info("Debug mode is disabled")
|
slog.Info("Debug mode is disabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.DisableWatchers {
|
||||||
|
slog.Info("Template watchers are disabled")
|
||||||
|
} else {
|
||||||
|
slog.Info("Template watchers are enabled")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -184,8 +184,9 @@ func (app *App) Serve() error {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if app.MAConfig.Debug {
|
if app.MAConfig.Debug && !app.MAConfig.DisableWatchers {
|
||||||
app.setWatchers(engine)
|
app.setWatchers(engine)
|
||||||
|
engine.Debug()
|
||||||
}
|
}
|
||||||
|
|
||||||
// INFO: we use OnServe, but here is also OnBootstrap
|
// INFO: we use OnServe, but here is also OnBootstrap
|
||||||
@@ -686,7 +687,6 @@ func (app *App) setWatchers(engine *templating.Engine) {
|
|||||||
} else {
|
} else {
|
||||||
watcher.AddRecursive(LAYOUT_DIR)
|
watcher.AddRecursive(LAYOUT_DIR)
|
||||||
watcher.AddRecursive(ROUTES_DIR)
|
watcher.AddRecursive(ROUTES_DIR)
|
||||||
engine.Debug()
|
|
||||||
rwatcher, err := RefreshWatcher(engine)
|
rwatcher, err := RefreshWatcher(engine)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.PB.Logger().Error("Failed to create watcher, continuing without", "error", err)
|
app.PB.Logger().Error("Failed to create watcher, continuing without", "error", err)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"debug": true,
|
"debug": true,
|
||||||
"allow_test_login": true
|
"allow_test_login": true,
|
||||||
|
"disable_watchers": false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user