From 359a2cacefdd14f57341a7449d022a8f0ec53342 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 27 Mar 2023 01:29:58 +0700 Subject: [PATCH] Fix khoj--server-running to work with unconfigured or external server - If khoj server started outside emacs, khoj--server-ready should be set to true by khoj--server-running method (instead of waiting for proc msg) - If khoj server is unconfigured the /config/types endpoint wouldn't return anything. Using config/data/default allows checking khoj server running status without requiring it to be configured as well --- src/interface/emacs/khoj.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/interface/emacs/khoj.el b/src/interface/emacs/khoj.el index c2aa013d..8bfaf782 100644 --- a/src/interface/emacs/khoj.el +++ b/src/interface/emacs/khoj.el @@ -281,13 +281,14 @@ for example), set this to the full interpreter path." (defun khoj--server-running? () "Check if the khoj server is running." - (or - ;; check for when server process handled from within emacs - (and khoj--server-process - (not (null (process-live-p khoj--server-process)))) - ;; else general check via ping to khoj-server-url - (ignore-errors - (not (null (khoj--get-enabled-content-types) t))))) + (when (or + ;; check for when server process handled from within emacs + (and khoj--server-process + (not (null (process-live-p khoj--server-process)))) + ;; else general check via ping to khoj-server-url + (ignore-errors + (not (null (url-retrieve-synchronously (format "%s/api/config/data/default" khoj-server-url)))))) + (setq khoj--server-ready? t))) (defun khoj--server-stop () "Stop the khoj server."