aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-12-18 10:21:01 +0300
committerMunyoki Kilyungi2025-01-06 22:24:58 +0300
commitdff37f58de5bb07af51b9959bae1498be1287274 (patch)
tree1cb465d63132072d210bb31428d8426f89229652
parentc3c4ad09a7f25da8990132e5549974438b329cb4 (diff)
downloadgn-machines-dff37f58de5bb07af51b9959bae1498be1287274.tar.gz
Add gn-guile service to genenetwork-shepherd-services.
* genenetwork-development-deploy.sh: share "/export/data/gn-docs/". * genenetwork-development.scm: Import gn-guile. (<genenetwork-configuration>)[gn-guile-port, gn-doc-git-checkout]: New fields. (gn-guile-gexp): New g-exp for running gn-guile. (genenetwork-shepherd-services): Add gn-guile service.
-rwxr-xr-xgenenetwork-development-deploy.sh1
-rw-r--r--genenetwork-development.scm58
2 files changed, 57 insertions, 2 deletions
diff --git a/genenetwork-development-deploy.sh b/genenetwork-development-deploy.sh
index 0757406..b251033 100755
--- a/genenetwork-development-deploy.sh
+++ b/genenetwork-development-deploy.sh
@@ -43,6 +43,7 @@ container_script=$(guix system container --network \
--share=/export/data/genenetwork-xapian \
--share=/export/data/genenetwork-sqlite \
--share=/var/run/mysqld=/run/mysqld \
+ --share=/export/data/gn-docs/ \
genenetwork-development.scm)
echo $container_script
diff --git a/genenetwork-development.scm b/genenetwork-development.scm
index 95c794d..3fcb1de 100644
--- a/genenetwork-development.scm
+++ b/genenetwork-development.scm
@@ -23,6 +23,7 @@
(use-modules (gnu)
((gn packages genenetwork) #:select (genenetwork2 genenetwork3 gn-auth))
(gn services databases)
+ ((gn packages guile) #:select (gn-guile))
(gnu build linux-container)
((gnu packages admin) #:select (shepherd shadow))
((gnu packages base) #:select (gnu-make tar))
@@ -145,7 +146,11 @@ be imported into G-expressions."
(auth-db-path genenetwork-auth-db-path
(default "/export/data/genenetwork-sqlite/auth.db"))
(llm-db-path genenetwork-llm-db-path
- (default "/export/data/genenetwork-sqlite/llm.db")))
+ (default "/export/data/genenetwork-sqlite/llm.db"))
+ (gn-guile-port genenetwork-configuration-gn-guile-port
+ (default 8091))
+ (gn-doc-git-checkout genenetwork-configuration-gn-doc-git-checkout
+ (default "/export/data/gn-docs")))
;;;
@@ -567,12 +572,59 @@ server described by CONFIG, a <genenetwork-configuration> object."
"--workers" "8"
"gn_auth.wsgi:app"))))))))
+(define (gn-guile-gexp gn-guile-port)
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+ (let ((current-repo-path (string-append (getcwd) "/gn-docs")))
+ (when (file-exists? current-repo-path)
+ (delete-file-recursively current-repo-path))
+ (setenv "CURRENT_REPO_PATH" current-repo-path)
+ (invoke #$(file-append git-minimal "/bin/git")
+ "clone" "--depth" "1" (getenv "CGIT_REPO_PATH")))
+ (invoke #$(file-append gn-guile "/bin/gn-guile")
+ (number->string #$gn-guile-port)))))
+
(define (genenetwork-shepherd-services config)
"Return shepherd services to run the genenetwork development server
described by CONFIG, a <genenetwork-configuration> object."
(match-record config <genenetwork-configuration>
- (gn2-port gn3-port gn-auth-port genotype-files data-directory xapian-db-path gn2-secrets auth-db-path gn-auth-secrets llm-db-path)
+ (gn2-port gn3-port gn-auth-port genotype-files data-directory xapian-db-path gn2-secrets auth-db-path gn-auth-secrets llm-db-path gn-doc-git-checkout gn-guile-port)
(list (shepherd-service
+ (documentation "Run gn-guile server.")
+ (provision '(gn-guile))
+ (requirement '(networking))
+ (modules '((ice-9 match)
+ (srfi srfi-1)))
+ (start
+ (let* ((gn-guile-settings
+ `(("CGIT_REPO_PATH" ,gn-doc-git-checkout)
+ ("LC_ALL" "en_US.UTF-8")
+ ("GIT_COMMITTER_NAME" "genenetwork")
+ ("GIT_COMMITTER_EMAIL" "no-reply@git.genenetwork.org"))))
+ #~(make-forkexec-constructor
+ (list #$(least-authority-wrapper
+ (program-file "gn-guile"
+ (gn-guile-gexp gn-guile-port))
+ #:name "gn-guile-pola-wrapper"
+ #:preserved-environment-variables
+ (map first gn-guile-settings)
+ #:mappings (list (file-system-mapping
+ (source gn-doc-git-checkout)
+ (target source)
+ (writable? #t)))
+ #:namespaces (delq 'net %namespaces))
+ "127.0.0.1" #$(number->string gn-guile-port))
+ #:user "genenetwork"
+ #:group "genenetwork"
+ #:environment-variables
+ (map (match-lambda
+ ((spec value)
+ (string-append spec "=" value)))
+ '#$gn-guile-settings)
+ #:log-file "/var/log/cd/gn-guile.log")))
+ (stop #~(make-kill-destructor)))
+ (shepherd-service
(documentation "Run GeneNetwork 2 development server.")
(provision '(genenetwork2))
;; FIXME: The genenetwork2 service should depend on redis.
@@ -739,6 +791,8 @@ described by CONFIG, a <genenetwork-configuration> object."
(cons* #$gn3-secrets
(append (find-files #$gn2-secrets
#:directories? #t)
+ (find-files "/export/data/gn-docs"
+ #:directories? #t)
(find-files #$(dirname auth-db-path)
#:directories? #t)
(find-files #$gn-auth-secrets