Просмотр исходного кода

bugfix: Start filewatcher on different goroutines (#286)

James Read 2 лет назад
Родитель
Сommit
5057ba2e1c
2 измененных файлов с 5 добавлено и 3 удалено
  1. 3 1
      internal/entityfiles/entityfiles.go
  2. 2 2
      internal/onfileindir/fileindir.go

+ 3 - 1
internal/entityfiles/entityfiles.go

@@ -35,9 +35,11 @@ func SetupEntityFileWatchers(cfg *config.Config) {
 			}).Debugf("Adding config dir to entity file path")
 			}).Debugf("Adding config dir to entity file path")
 		}
 		}
 
 
-		filehelper.WatchFileWrite(p, func(filename string) {
+		go filehelper.WatchFileWrite(p, func(filename string) {
 			loadEntityFile(p, ef.Name)
 			loadEntityFile(p, ef.Name)
 		})
 		})
+
+		loadEntityFile(p, ef.Name)
 	}
 	}
 }
 }
 
 

+ 2 - 2
internal/onfileindir/fileindir.go

@@ -10,13 +10,13 @@ import (
 func WatchFilesInDirectory(cfg *config.Config, ex *executor.Executor) {
 func WatchFilesInDirectory(cfg *config.Config, ex *executor.Executor) {
 	for _, action := range cfg.Actions {
 	for _, action := range cfg.Actions {
 		for _, dirname := range action.ExecOnFileChangedInDir {
 		for _, dirname := range action.ExecOnFileChangedInDir {
-			filehelper.WatchDirectoryWrite(dirname, func(filename string) {
+			go filehelper.WatchDirectoryWrite(dirname, func(filename string) {
 				scheduleExec(action, cfg, ex, filename)
 				scheduleExec(action, cfg, ex, filename)
 			})
 			})
 		}
 		}
 
 
 		for _, dirname := range action.ExecOnFileCreatedInDir {
 		for _, dirname := range action.ExecOnFileCreatedInDir {
-			filehelper.WatchDirectoryCreate(dirname, func(filename string) {
+			go filehelper.WatchDirectoryCreate(dirname, func(filename string) {
 				scheduleExec(action, cfg, ex, filename)
 				scheduleExec(action, cfg, ex, filename)
 			})
 			})
 		}
 		}