about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-02-20 12:44:53 -0600
committerFrederick Muriuki Muriithi2025-02-21 08:07:49 -0600
commit32302924ec92e6d47d0a3089fe1678269c16a8f6 (patch)
tree5f0ba99c35ef919fffeee20f0a4138e6a658fecb
parent5ddadff51d560da91c2ac5a4a12b2559392cadf6 (diff)
downloadgn-machines-32302924ec92e6d47d0a3089fe1678269c16a8f6.tar.gz
Split the tempdirs for various applications.
-rw-r--r--genenetwork/services/genenetwork.scm39
1 files changed, 31 insertions, 8 deletions
diff --git a/genenetwork/services/genenetwork.scm b/genenetwork/services/genenetwork.scm
index a3c0e73..360a6e3 100644
--- a/genenetwork/services/genenetwork.scm
+++ b/genenetwork/services/genenetwork.scm
@@ -275,8 +275,6 @@
                             (find-files #$genotype-files
                                         #:directories? #t)
                             (find-files #$gn2-secrets
-                                        #:directories? #t)
-                            (find-files #$gn-tmpdir
                                         #:directories? #t)))
           (for-each (lambda (file)
                       (chown file
@@ -292,7 +290,23 @@
                             (find-files #$gn2-secrets
                                         #:directories? #f)
                             (find-files #$gn-auth-secrets
-                                        #:directories? #f)))))))
+                                        #:directories? #f)))
+          ;; Make sub-directories for various apps under gn-tmpdir and assign
+          ;; appropriate permissions
+          (for-each (match-lambda
+                      ((subdir user)
+                       (let ((full-path
+                              (string-append #$gn-tmpdir "/" subdir)))
+                         (unless (file-exists? full-path)
+                           (mkdir full-path #o755))
+                         (for-each (lambda (file)
+                                     (chown file
+                                            (passwd:uid (getpw user))
+                                            (passwd:gid (getpw user))))
+                                   (find-files full-path
+                                               #:directories? #t)))))
+                    '(("gn2-tmpdir" "gunicorn-genenetwork2")
+                      ("gn3-tmpdir" "gunicorn-genenetwork3")))))))
 
 (define (configuration-file-gexp alist)
   "Return a G-expression that constructs a configuration file of
@@ -374,7 +388,9 @@ object."
                                            ("AUTH_DB" ,auth-db)
                                            ("SQL_URI" ,sql-uri)
                                            ("CLIENTS_SSL_PUBLIC_KEYS_DIR" ,(string-append gn-auth-secrets "/clients-public-keys"))
-                                           ("SSL_PRIVATE_KEY" ,(string-append gn-auth-secrets "/gn-auth-ssl-private-key.pem")))))))
+                                           ("SSL_PRIVATE_KEY" ,(string-append gn-auth-secrets "/gn-auth-ssl-private-key.pem"))))))
+           (gn2-tmpdir (string-append gn-tmpdir "/gn2-tmpdir"))
+           (gn3-tmpdir (string-append gn-tmpdir "/gn3-tmpdir")))
       (list (gunicorn-app
              (name "genenetwork2")
              (package genenetwork2)
@@ -389,7 +405,7 @@ object."
                      (value gn2-profile))
                     (environment-variable
                      (name "TMPDIR")
-                     (value gn-tmpdir))
+                     (value gn2-tmpdir))
                     (environment-variable
                      (name "GN2_SETTINGS")
                      (value gn2-conf))
@@ -407,8 +423,11 @@ object."
                              (file-system-mapping
                               (source gn-sourcecode-directory)
                               (target source))
-                             (file-system-mapping ; GN2 and GN3 need to share TMPDIR
+                             (file-system-mapping ; GN2 and GN3 need to communicate via TMPDIR
                               (source gn-tmpdir)
+                              (target source))
+                             (file-system-mapping
+                              (source gn2-tmpdir)
                               (target source)
                               (writable? #t))
                              (file-system-mapping
@@ -444,7 +463,7 @@ object."
                      (value gn3-conf))
                     (environment-variable
                      (name "TMPDIR")
-                     (value gn-tmpdir))
+                     (value gn3-tmpdir))
                     (environment-variable
                      (name "GN3_SECRETS")
                      (value gn3-secrets))
@@ -470,10 +489,14 @@ object."
                              (file-system-mapping
                               (source gn3-data-directory)
                               (target source))    ; Rqtl usese this
-                             (file-system-mapping ; GN2 and GN3 need to share TMPDIR
+                             (file-system-mapping ; GN2 and GN3 need to communicate via TMPDIR
                               (source gn-tmpdir)
                               (target source))
                              (file-system-mapping
+                              (source gn3-tmpdir)
+                              (target source)
+                              (writable? #t))
+                             (file-system-mapping
                               (source xapian-db)
                               (target source))
                              (file-system-mapping