git.iko.soy/typeable/nixpkgs
on master help sign in
epmd: Introduce erlang port mapper daemon service

Having socket-activated epmd means that there always be only a single instance managed centrally. Because Erlang also starts it automatically if not available, and in worst case scenario 'epmd' can be started by some Erlang application running under systemd. And then restarting this application unit will cause complete loss of names in 'epmd' (if other Erlang system are also installed on this host). E.g. see at which lengths RabbitMQ goes to recover from such situations: https://github.com/rabbitmq/rabbitmq-server/blame/7741b37b1efa97ac9b17685cc626bd35ee52ca16/src/rabbit_epmd_monitor.erl#L36 Having the only one socket-activated epmd completely solves this problem.

commitc00d17aae388bca8bf5657a2f312a1e436e7aef0 authorAlexey Lebedeff <alexey.lebedeff@booking.com> dateThu 25 Jan 2018, 20:28 (9 years ago) parent16cccc2
2 files changed+57
nixos/modules/module-list.nix+1 nixos/modules/services/networking/epmd.nix+56
nixos/modules/module-list.nix+1
@@ -484,6 +484,7 @@
484484 ./services/networking/dnsdist.nix
485485 ./services/networking/dnsmasq.nix
486486 ./services/networking/ejabberd.nix
487+ ./services/networking/epmd.nix
487488 ./services/networking/fakeroute.nix
488489 ./services/networking/ferm.nix
489490 ./services/networking/firefox/sync-server.nix
nixos/modules/services/networking/epmd.nixnew file+56
@@ -0,0 +1,56 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.epmd;
7+
8+in
9+
10+{
11+ ###### interface
12+ options.services.epmd = {
13+ enable = mkOption {
14+ type = types.bool;
15+ default = false;
16+ description = ''
17+ Whether to enable socket activation for Erlang Port Mapper Daemon (epmd),
18+ which acts as a name server on all hosts involved in distributed
19+ Erlang computations.
20+ '';
21+ };
22+ package = mkOption {
23+ type = types.package;
24+ default = pkgs.erlang;
25+ description = ''
26+ The Erlang package to use to get epmd binary. That way you can re-use
27+ an Erlang runtime that is already installed for other purposes.
28+ '';
29+ };
30+ };
31+
32+ ###### implementation
33+ config = mkIf cfg.enable {
34+ systemd.sockets.epmd = rec {
35+ description = "Erlang Port Mapper Daemon Activation Socket";
36+ wantedBy = [ "sockets.target" ];
37+ before = wantedBy;
38+ socketConfig = {
39+ ListenStream = "4369";
40+ Accept = "false";
41+ };
42+ };
43+
44+ systemd.services.epmd = {
45+ description = "Erlang Port Mapper Daemon";
46+ after = [ "network.target" ];
47+ requires = [ "epmd.socket" ];
48+
49+ serviceConfig = {
50+ DynamicUser = true;
51+ ExecStart = "${cfg.package}/bin/epmd -systemd";
52+ Type = "notify";
53+ };
54+ };
55+ };
56+}