Skip to content

Commit 5217df4

Browse files
committed
Make dev mode reload less aggresive
1 parent 11c1e4b commit 5217df4

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

internal/app/app.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"time"
2222

2323
"github.com/BurntSushi/toml"
24+
"github.com/bmatcuk/doublestar/v4"
2425
"github.com/fsnotify/fsnotify"
2526
"github.com/go-chi/chi"
2627
"github.com/openrundev/openrun/internal/app/action"
@@ -662,6 +663,24 @@ func (a *App) startWatcher() error {
662663
a.Trace().Str("event", fmt.Sprint(event)).Msg("Ignoring event since reload happened recently")
663664
continue
664665
}
666+
if !(event.Has(fsnotify.Create) || event.Has(fsnotify.Write) || event.Has(fsnotify.Remove) || event.Has(fsnotify.Rename)) {
667+
// ignore chmod events
668+
a.Trace().Str("event", fmt.Sprint(event)).Msg("Ignoring event")
669+
continue
670+
}
671+
672+
foundIgnoreMatch := false
673+
for _, pattern := range a.systemConfig.WatchIgnorePatterns {
674+
if match, err := doublestar.Match(pattern, event.Name); err == nil && match {
675+
a.Trace().Str("event", fmt.Sprint(event)).
676+
Msgf("Ignoring event on %s since it matches ignore pattern %s", event.Name, pattern)
677+
foundIgnoreMatch = true
678+
continue
679+
}
680+
}
681+
if foundIgnoreMatch {
682+
continue
683+
}
665684

666685
a.Trace().Str("event", fmt.Sprint(event)).Msg("Received event")
667686

internal/system/openrun.default.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ file_cache_connection = "sqlite:$OPENRUN_HOME/metadata/file_cache.db"
5959
[system]
6060
tailwindcss_command = "tailwindcss"
6161
file_watcher_debounce_millis = 300
62+
watch_ignore_patterns = ["**/.vscode/**", "**/.idea/**", "**/.git/**", "**/.DS_Store/**", "**/.*sw*"] # patterns to ignore for file watcher
6263
node_path = "" # node module lookup paths https://esbuild.github.io/api/#node-paths
6364
container_command = "auto" # "auto" or "docker" or "podman"
6465
default_domain = "localhost" # default domain for apps

internal/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ type LogConfig struct {
218218
type SystemConfig struct {
219219
TailwindCSSCommand string `toml:"tailwindcss_command"`
220220
FileWatcherDebounceMillis int `toml:"file_watcher_debounce_millis"`
221+
WatchIgnorePatterns []string `toml:"watch_ignore_patterns"`
221222
NodePath string `toml:"node_path"`
222223
ContainerCommand string `toml:"container_command"`
223224
DefaultDomain string `toml:"default_domain"`

0 commit comments

Comments
 (0)