aboutsummaryrefslogtreecommitdiff
path: root/gn/services
diff options
context:
space:
mode:
authorEfraim Flashner2019-12-22 03:49:03 -0600
committerEfraim Flashner2019-12-22 03:49:03 -0600
commit5856fb3878e69a2091afbfdd3b15268e310f82e3 (patch)
treea4bd7cf668275279bcbf01ede37954f8087d7172 /gn/services
parent3035ea5144af76b6ff260b1bceef3feafec8a177 (diff)
downloadguix-bioinformatics-5856fb3878e69a2091afbfdd3b15268e310f82e3.tar.gz
gn: Update bnw service
Diffstat (limited to 'gn/services')
-rw-r--r--gn/services/bnw-README14
-rw-r--r--gn/services/bnw-container.scm88
2 files changed, 74 insertions, 28 deletions
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")))
+ ))))