From 2d9291a7f24268ce58a3d98a4ad9a16a05665df0 Mon Sep 17 00:00:00 2001 From: Oscar Najera Date: Thu, 7 Dec 2023 11:24:09 +0100 Subject: run roam semantic search as shepherd daemon --- config/shepherd/init.d/my-daemons.scm | 14 ++++++++++++++ config/shepherd/init.scm | 2 +- scratch/semgrep/semgrep.el | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/config/shepherd/init.d/my-daemons.scm b/config/shepherd/init.d/my-daemons.scm index 6388850..1b5daf8 100644 --- a/config/shepherd/init.d/my-daemons.scm +++ b/config/shepherd/init.d/my-daemons.scm @@ -16,3 +16,17 @@ #:log-file "/tmp/habits.log") #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C #:respawn? #t)) + +(let ((workdir (string-append (getenv "HOME") "/dev/dotfiles/scratch/semgrep/"))) + (register-services + (make + #:docstring "Roam semantic DB" + #:provides '(roam-semantic-db) + #:start (make-forkexec-constructor + (list "python" + (string-append workdir "server.py")) + #:directory workdir + #:environment-variables (list (string-append "PATH=" (getenv "HOME") "/.virtualenvs/language/bin")) + #:log-file "/tmp/roam-semantic.log") + #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C + #:respawn? #t))) diff --git a/config/shepherd/init.scm b/config/shepherd/init.scm index c94b034..3d47bd4 100644 --- a/config/shepherd/init.scm +++ b/config/shepherd/init.scm @@ -22,4 +22,4 @@ ;; Services to start when shepherd starts: ;; Add the name of each service that should be started to the list ;; below passed to 'for-each'. -(for-each start '(habit-logs)) +(for-each start '(habit-logs roam-semantic-db)) diff --git a/scratch/semgrep/semgrep.el b/scratch/semgrep/semgrep.el index 37ba800..a93803b 100644 --- a/scratch/semgrep/semgrep.el +++ b/scratch/semgrep/semgrep.el @@ -67,7 +67,7 @@ (org-element-map (org-element-parse-buffer) 'paragraph - (semgrep--prepare-paragraph (org-id-get (point-min)))) + (semgrep--prepare-paragraph (org-id-get (point-min) 'create))) (cl-coerce it 'vector) ;; (json-serialize it) ;; (f-write it 'utf-8 "/tmp/out.json") @@ -123,7 +123,7 @@ (format "* [[file:%s::%d][%s]]\n" file pos title) "- Distance :: " (number-to-string d) "\n" paragraph ?\n) - (fill-paragraph)))) + (org-fill-paragraph)))) entry-distances entry-document entry-metadatas))) distances documents metadatas) (goto-char (point-min)) -- cgit v1.2.3