From a046dcac5eb5d647e21cefb92a189dbd0255518f Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Mon, 18 Mar 2024 19:14:48 +0100 Subject: [PATCH] fix(config-watcher): start only if config-directory exists (#1854) Signed-off-by: Ettore Di Giacinto --- main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 169c3400..400dcb57 100644 --- a/main.go +++ b/main.go @@ -306,11 +306,16 @@ For a list of compatible model, check out: https://localai.io/model-compatibilit return fmt.Errorf("failed basic startup tasks with error %s", err.Error()) } - closeConfigWatcherFn, err := startup.WatchConfigDirectory(ctx.String("localai-config-dir"), options) - defer closeConfigWatcherFn() + configdir := ctx.String("localai-config-dir") + // Watch the configuration directory + // If the directory does not exist, we don't watch it + if _, err := os.Stat(configdir); err == nil { + closeConfigWatcherFn, err := startup.WatchConfigDirectory(ctx.String("localai-config-dir"), options) + defer closeConfigWatcherFn() - if err != nil { - return fmt.Errorf("failed while watching configuration directory %s", ctx.String("localai-config-dir")) + if err != nil { + return fmt.Errorf("failed while watching configuration directory %s", ctx.String("localai-config-dir")) + } } appHTTP, err := http.App(cl, ml, options)