mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +00:00
hot reload, search refactor begin
This commit is contained in:
23
app/pb.go
23
app/pb.go
@@ -120,20 +120,21 @@ func (app *App) Serve() error {
|
||||
|
||||
// INFO: hot reloading for poor people
|
||||
if app.MAConfig.Debug {
|
||||
watcher, err := fsnotify.NewWatcher()
|
||||
watcher, err := EngineWatcher(engine)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to create watcher: %w.", err)
|
||||
}
|
||||
defer watcher.Close()
|
||||
|
||||
go app.watchFN(watcher, engine)
|
||||
if err := watcher.Add(LAYOUT_DIR); err != nil {
|
||||
return fmt.Errorf("Failed to watch layout directory: %w.", err)
|
||||
app.PB.Logger().Error("Failed to create watcher, continuing without", "error", err)
|
||||
} 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)
|
||||
} else {
|
||||
rwatcher.Add("./views/assets")
|
||||
}
|
||||
}
|
||||
|
||||
if err := watcher.Add(ROUTES_DIR); err != nil {
|
||||
return fmt.Errorf("Failed to watch routes directory: %w.", err)
|
||||
}
|
||||
}
|
||||
|
||||
app.PB.OnBootstrap().BindFunc(func(e *core.BootstrapEvent) error {
|
||||
|
||||
Reference in New Issue
Block a user