diff options
| author | wrobell <wrobell@riseup.net> | 2026-06-16 20:17:41 +0100 |
|---|---|---|
| committer | Nguyễn Gia Phong <cnx@loang.net> | 2026-07-26 15:23:19 +0900 |
| commit | ce8df300216b308720903e6da9e01d246143b47f (patch) | |
| tree | 6184790b895796fd3621bf753daddc4471449ee3 /gnu/services | |
| parent | 47b41dced835020f803dc56f52e949c94d2f7061 (diff) | |
services: Add epmd-service-type.
Add Erlang Port Mapper Daemon (epmd) service.
Run the service on localhost by default.
* gnu/services/high-availability.scm (<epmd-configuration>): New record.
(epmd-service-type): New variable.
* gnu/tests/high-availability.scm (run-epmd-test): New procedure.
(%epmd-os, %tests-epmd): New variables.
* doc/gnu.texi (High Availability Services): Document it.
Merges: https://codeberg.org/guix/guix/pulls/9607
References: https://www.rabbitmq.com/blog/2024/12/18/epmd-public-exposure
References: https://erlef.org/blog/eef/epmd-public-exposure
Signed-off-by: Nguyễn Gia Phong <cnx@loang.net>
Diffstat (limited to 'gnu/services')
| -rw-r--r-- | gnu/services/high-availability.scm | 81 |
1 files changed, 74 insertions, 7 deletions
diff --git a/gnu/services/high-availability.scm b/gnu/services/high-availability.scm index 73d534cf020..8b928e76168 100644 --- a/gnu/services/high-availability.scm +++ b/gnu/services/high-availability.scm | |||
| @@ -20,8 +20,10 @@ | |||
| 20 | 20 | ||
| 21 | (define-module (gnu services high-availability) | 21 | (define-module (gnu services high-availability) |
| 22 | #:use-module (gnu packages admin) | 22 | #:use-module (gnu packages admin) |
| 23 | #:use-module (gnu packages erlang) | ||
| 23 | #:use-module (gnu packages high-availability) | 24 | #:use-module (gnu packages high-availability) |
| 24 | #:use-module (gnu services) | 25 | #:use-module (gnu services) |
| 26 | #:use-module (gnu services configuration) | ||
| 25 | #:use-module (gnu services shepherd) | 27 | #:use-module (gnu services shepherd) |
| 26 | #:use-module (gnu system shadow) | 28 | #:use-module (gnu system shadow) |
| 27 | #:use-module (guix gexp) | 29 | #:use-module (guix gexp) |
| @@ -30,13 +32,78 @@ | |||
| 30 | #:use-module (ice-9 match) | 32 | #:use-module (ice-9 match) |
| 31 | #:use-module (ice-9 format) | 33 | #:use-module (ice-9 format) |
| 32 | 34 | ||
| 33 | #:export (rabbitmq-configuration rabbitmq-configuration? | 35 | #:export (epmd-configuration |
| 34 | rabbitmq-configuration-rabbitmq | 36 | epmd-configuration-fields |
| 35 | rabbitmq-configuration-node-name | 37 | epmd-configuration? |
| 36 | rabbitmq-configuration-config-file | 38 | epmd-configuration-user |
| 37 | rabbitmq-configuration-env-config-file | 39 | epmd-configuration-group |
| 38 | rabbitmq-configuration-plugins | 40 | epmd-configuration-address |
| 39 | rabbitmq-service-type)) | 41 | epmd-configuration-port |
| 42 | epmd-service-type | ||
| 43 | |||
| 44 | rabbitmq-configuration | ||
| 45 | rabbitmq-configuration? | ||
| 46 | rabbitmq-configuration-rabbitmq | ||
| 47 | rabbitmq-configuration-node-name | ||
| 48 | rabbitmq-configuration-config-file | ||
| 49 | rabbitmq-configuration-env-config-file | ||
| 50 | rabbitmq-configuration-plugins | ||
| 51 | rabbitmq-service-type)) | ||
| 52 | |||
| 53 | (define-configuration/no-serialization epmd-configuration | ||
| 54 | (user (string "epmd") "The user running epmd.") | ||
| 55 | (group (string "epmd") "The user group running epmd.") | ||
| 56 | ;; The address default works for IPv4-only or IPv6-only systems. For example, | ||
| 57 | ;; epmd shows warning for ::1 on IPv4-only system, but starts anyway. | ||
| 58 | (address (list-of-strings (list "127.0.0.1" "::1")) | ||
| 59 | "List of addresses for epmd to listen on. Set it to false | ||
| 60 | (@code{#f}) to listen on all available addresses. Note that epmd cannot start | ||
| 61 | on @code{\"0.0.0.0\"} address.") | ||
| 62 | (port (integer 4369) "Default port for epmd to listen on.")) | ||
| 63 | |||
| 64 | (define (epmd-accounts config) | ||
| 65 | (match-record config <epmd-configuration> (user group) | ||
| 66 | (list (user-group (name group) | ||
| 67 | (system? #t)) | ||
| 68 | (user-account (name user) | ||
| 69 | (group group) | ||
| 70 | (system? #t) | ||
| 71 | (comment "Erlang Port Mapper Daemon user") | ||
| 72 | (home-directory "/var/empty") | ||
| 73 | (shell (file-append shadow "/sbin/nologin")))))) | ||
| 74 | |||
| 75 | (define (epmd-shepherd-service config) | ||
| 76 | (match-record config <epmd-configuration> | ||
| 77 | (address port) | ||
| 78 | (let ((address-list (if address (string-join address ",") #f))) | ||
| 79 | (with-imported-modules | ||
| 80 | (source-module-closure '((gnu build shepherd))) | ||
| 81 | (list | ||
| 82 | (shepherd-service | ||
| 83 | (provision '(epmd)) | ||
| 84 | (documentation "Run the Erlang Port Mapper Daemon (epmd).") | ||
| 85 | (requirement '(user-processes loopback)) | ||
| 86 | (modules '((gnu build shepherd))) | ||
| 87 | (start | ||
| 88 | #~(make-forkexec-constructor | ||
| 89 | (append (list #$(file-append erlang "/bin/epmd") | ||
| 90 | "-port" | ||
| 91 | #$(number->string port)) | ||
| 92 | (if #$address-list | ||
| 93 | (list "-address" #$address-list) | ||
| 94 | (list))) | ||
| 95 | #:user "epmd" | ||
| 96 | #:group "epmd")) | ||
| 97 | (stop #~(make-kill-destructor)))))))) | ||
| 98 | |||
| 99 | (define epmd-service-type | ||
| 100 | (service-type | ||
| 101 | (name 'epmd) | ||
| 102 | (description "Run the Erlang Port Mapper Daemon (epmd).") | ||
| 103 | (extensions (list (service-extension shepherd-root-service-type | ||
| 104 | epmd-shepherd-service) | ||
| 105 | (service-extension account-service-type epmd-accounts))) | ||
| 106 | (default-value (epmd-configuration)))) | ||
| 40 | 107 | ||
| 41 | ;; By default, start messaging and inter-node RabbitMQ listeners on local | 108 | ;; By default, start messaging and inter-node RabbitMQ listeners on local |
| 42 | ;; interfaces only, see also: | 109 | ;; interfaces only, see also: |
