aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEfraim Flashner2019-12-22 03:49:03 -0600
committerEfraim Flashner2019-12-22 03:49:03 -0600
commit5856fb3878e69a2091afbfdd3b15268e310f82e3 (patch)
treea4bd7cf668275279bcbf01ede37954f8087d7172
parent3035ea5144af76b6ff260b1bceef3feafec8a177 (diff)
downloadguix-bioinformatics-5856fb3878e69a2091afbfdd3b15268e310f82e3.tar.gz
gn: Update bnw service
-rw-r--r--gn/packages/bnw.scm12
-rw-r--r--gn/services/bnw-README14
-rw-r--r--gn/services/bnw-container.scm88
3 files changed, 84 insertions, 30 deletions
diff --git a/gn/packages/bnw.scm b/gn/packages/bnw.scm
index f7e95e3..5b7131b 100644
--- a/gn/packages/bnw.scm
+++ b/gn/packages/bnw.scm
@@ -44,6 +44,9 @@
(substitute* (find-files "." "\\.php")
(("HTTP_POST_VARS") "_POST")
(("HTTP_POST_FILES") "_FILES"))
+ ;; change $dir to a writable directory
+ ;(substitute* (find-files "sourcecodes" "\\.php$")
+ ; (("\\$dir=\"./data") "$dir=\"./data/tmp"))
#t))
(add-after 'patch-source-shebangs 'patch-more-shebangs
(lambda* (#:key inputs #:allow-other-keys)
@@ -84,6 +87,11 @@
(substitute* '("sourcecodes/build.sh"
"downloads/BNW/src/build.sh")
(("./localscore/libRmath.so") (string-append rmath "/lib/libRmath.so")))
+ (substitute* "sourcecodes/run.sh"
+ (("rm ") (string-append (which "rm") " "))
+ (("rmdir ") (string-append (which "rmdir") " "))
+ (("mkdir ") (string-append (which "mkdir") " "))
+ (("dirname ") (string-append (which "dirname")" ")))
;(substitute* "sourcecodes/layout_cyto.php"
; (("https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.7.1/cytoscape.min.js")
; (string-append cyto js-path "cytoscape/cytoscape.min.js"))
@@ -127,8 +135,8 @@
(lambda (file)
(chmod file #o555))
(append (find-files out "\\.(sh|py)$")
- (find-files (string-append out "/sourcecodes/run_scripts" ".*"))
- ))
+ (find-files (string-append out "/sourcecodes/run_scripts/" "."))))
+ (chmod (string-append out "/sourcecodes/data") #o777) ; needs to be writable
#t)))
(replace 'build
(lambda _
diff --git a/gn/services/bnw-README b/gn/services/bnw-README
index 29cc816..ab7de53 100644
--- a/gn/services/bnw-README
+++ b/gn/services/bnw-README
@@ -1,10 +1,9 @@
SETUP:
The setup process works like this:
-$ guix build bnw
-$ mkdir -p /home/bnw/server/bnw
-$ cp -a $(guix build bnw)/* /home/bnw/server/bnw/
-$ chmod a+w /home/bnw/server -R
+$ guix pull
+$ cd guix-bioinformatics && git pull
+# systemctl enable --now bnw.service
for testing changes to the container, you'll want to do the following (or thereabouts):
$ guix system container gn/services/GN1-container.scm --share=/home/bnw/server=/srv/http --network
@@ -15,8 +14,5 @@ see included bnw.service
for upgrades:
$ guix pull
-$ rm -rf /home/bnw/server
-$ guix build bnw
-$ mkdir -p /home/bnw/server/bnw
-$ cp -a $(guix build bnw)/* /home/bnw/server/bnw/
-$ chmod a+w /home/bnw/server -R
+$ cd guix-bioinformatics && git pull
+# systemctl restart bnw.service
diff --git a/gn/services/bnw-container.scm b/gn/services/bnw-container.scm
index 13a9317..2e5e521 100644
--- a/gn/services/bnw-container.scm
+++ b/gn/services/bnw-container.scm
@@ -1,8 +1,69 @@
(define-module (gn services bnw-container))
(use-modules (gnu)
- (gn packages bnw))
-(use-service-modules base networking web)
+ (gn packages bnw)
+ (guix records)
+ (ice-9 match))
+(use-service-modules networking web)
+
+(define-record-type* <bnw-configuration>
+ bnw-configuration
+ make-bnw-configuration
+ bnw-configuration?
+ (package bnw-configuration-package ; package
+ (default bnw))
+ (deploy-directory bnw-deploy-directory ; string
+ (default "/home/bnw/server"))
+ (port bnw-configuration-port ; list of strings
+ (default '("8880"))))
+
+(define bnw-activation
+ (match-lambda
+ (($ <bnw-configuration> package deploy-directory port)
+ #~(begin
+ (use-modules (guix build utils))
+ (when (directory-exists? #$deploy-directory)
+ (delete-file-recusively #$deploy-directory))
+ (mkdir-p #$deploy-directory)
+ (copy-recursively #$package #$deploy-directory)
+ (system* #$(file-append coreutils "/bin/chmod") "a+w"
+ (string-append #$deploy-directory "/sourcecodes/data"))))))
+
+(define bnw-nginx-config
+ (match-lambda
+ (($ <bnw-configuration> package deploy-directory port)
+ (list
+ (nginx-server-configuration
+ (server-name '("Bayesian Network"))
+ (listen port)
+ ;(root package)
+ (root "/srv/http")
+ (locations
+ (list
+ (nginx-php-location)
+ ;(nginx-location-configuration
+ ; (uri "/sourcecodes/data/")
+ ; (body (list "alias /tmp/bnw/;")))
+ )))))))
+
+(define bnw-service-type
+ (service-type
+ (name 'bnw)
+ (extensions
+ (list
+ (service-extension activation-service-type
+ bnw-activation)
+ (service-extension nginx-service-type
+ bnw-nginx-config)
+ ;; Make sure BNW doesn't get garbage collected.
+ (service-extension profile-service-type
+ (compose list bnw-configuration-package))
+ ;; Make sure php-fpm is instantiated.
+ (service-extension php-fpm-service-type
+ (const #t))))
+ (default-value (bnw-configuration))
+ (description
+ "Run a Bayesian Network Webserver.")))
(operating-system
(host-name "bnw")
@@ -17,20 +78,9 @@
(firmware '())
(services (list (service dhcp-client-service-type)
- (service php-fpm-service-type)
- (service nginx-service-type
- (nginx-configuration
- (server-blocks
- (list
- (nginx-server-configuration
- (server-name '("Bayesian Network"))
- (listen '("8888"))
- (root bnw)
- (locations
- (list
- (nginx-php-location)
- (nginx-location-configuration
- (uri "/sourcecodes/data/")
- (body (list "alias /tmp/bnw/;")))
- ))
- ))))))))
+ (service bnw-service-type
+ ;; The following is for testing:
+ ;(bnw-configuration
+ ; (deploy-directory "/home/efraimf/bnw")
+ ; (port '("8888")))
+ ))))