about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2026-01-07 19:57:34 +0300
committerMunyoki Kilyungi2026-01-13 17:09:38 +0300
commit9afc819aa9e1930d25bda723cf8e829c944f09a3 (patch)
tree5cf6fbeb74255a4a0d7ffa7a0e07df023c1acf06
parentbc80b7d3beb4dade9cb448dce53f1a46218c51bf (diff)
downloadgn-machines-9afc819aa9e1930d25bda723cf8e829c944f09a3.tar.gz
Add sheepdog as a service.
-rw-r--r--guix/gn-machines/services/monitoring.scm68
1 files changed, 68 insertions, 0 deletions
diff --git a/guix/gn-machines/services/monitoring.scm b/guix/gn-machines/services/monitoring.scm
new file mode 100644
index 0000000..7fa59c9
--- /dev/null
+++ b/guix/gn-machines/services/monitoring.scm
@@ -0,0 +1,68 @@
+;;; genenetwork-machines --- Guix configuration for genenetwork machines
+;;; Copyright © 2025 Munyoki Kilyungi <me@bonfacemunyoki.com>
+;;;
+;;; This file is part of genenetwork-machines.
+;;;
+;;; genenetwork-machines is free software: you can redistribute it
+;;; and/or modify it under the terms of the GNU General Public License
+;;; as published by the Free Software Foundation, either version 3 of
+;;; the License, or (at your option) any later version.
+;;;
+;;; genenetwork-machines is distributed in the hope that it will be
+;;; useful, but WITHOUT ANY WARRANTY; without even the implied
+;;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+;;; See the GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with genenetwork-machines.  If not, see
+;;; <https://www.gnu.org/licenses/>.
+
+(define-module (gn-machines services monitoring)
+  #:use-module (gnu)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu services databases)
+  #:use-module ((gn-machines genenetwork) #:select (guile-sheepdog))
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+  #:use-module (ice-9 match)
+  #:export (guile-sheepdog-configuration
+	    guile-sheepdog-configuration?
+	    guile-sheepdog-configuration-settings-file
+	    guile-sheepdog-configuration-package
+	    guile-sheepdog-service-type))
+
+(define-record-type* <guile-sheepdog-configuration>
+  guile-sheepdog-configuration
+  make-guile-sheepdog-configuration
+  guile-sheepdog-configuration?
+  (settings-file guile-sheepdog-configuration-settings-file
+		 (default "/etc/conn.scm"))
+  (package guile-sheepdog-configuration-package (default guile-sheepdog)))
+
+(define (guile-sheepdog-gexp config)
+  (match-record config <guile-sheepdog-configuration> (settings-file package)
+    (program-file
+     "guile-sheepdog"
+     (with-imported-modules '((guix build utils))
+       #~(begin
+	   (use-modules (guix build utils))
+	   (invoke #$(file-append package "/bin/guile-sheepdog") #$settings-file))))))
+
+(define (guile-sheepdog-shepherd-service config)
+  (shepherd-service
+      (documentation "Run Sheepdog")
+      (provision '(guile-sheepdog))
+      (requirement '(networking redis))
+      (start #~(make-forkexec-constructor
+		(list #$(guile-sheepdog-gexp config))
+		#:log-file "/var/log/sheepdog.log"))
+      (stop #~(make-kill-destructor))))
+
+(define guile-sheepdog-service-type
+  (service-type
+   (name 'guile-sheepdog)
+   (description "Run sheepdog monitor")
+   (extensions
+    (list (service-extension shepherd-root-service-type
+                             (compose list guile-sheepdog-shepherd-service))))
+   (default-value (guile-sheepdog-configuration))))