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
This commit is contained in:
Debanjum Singh Solanky
2023-03-27 01:29:58 +07:00
parent d7fb9a596e
commit 359a2cacef

View File

@@ -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."