mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-06-08 00:23:48 +02:00
Read in tagger config on startup. Safeguard watcher shutdown
This commit is contained in:
parent
85f17c0fd8
commit
9abc206d1a
@ -51,6 +51,7 @@ func (t *AppTagger) EventMatch(s string) bool {
|
|||||||
return strings.Contains(s, "apps")
|
return strings.Contains(s, "apps")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Only process the file that caused the event
|
||||||
func (t *AppTagger) EventCallback() {
|
func (t *AppTagger) EventCallback() {
|
||||||
files, err := os.ReadDir(appPath)
|
files, err := os.ReadDir(appPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -85,6 +86,7 @@ func (t *AppTagger) Register() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if util.CheckFileExists(appPath) {
|
if util.CheckFileExists(appPath) {
|
||||||
|
t.EventCallback()
|
||||||
log.Infof("Setup file watch for %s", appPath)
|
log.Infof("Setup file watch for %s", appPath)
|
||||||
util.AddListener(appPath, t)
|
util.AddListener(appPath, t)
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,9 @@ func AddListener(path string, l Listener) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func FsWatcherShutdown() {
|
func FsWatcherShutdown() {
|
||||||
w.Close()
|
if w != nil {
|
||||||
|
w.Close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func watchLoop(w *fsnotify.Watcher) {
|
func watchLoop(w *fsnotify.Watcher) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user