diff options
author | Alexey Lebedeff <alexey.lebedeff@booking.com> | 2018-01-25 20:28:58 +0100 |
---|---|---|
committer | Alexey Lebedeff <binarin@binarin.ru> | 2018-07-19 17:32:29 +0200 |
commit | c00d17aae388bca8bf5657a2f312a1e436e7aef0 (patch) | |
tree | 999b7f526bc14c57527caf4232f2087ae9feb136 /nixos/modules/services/networking/epmd.nix | |
parent | 16cccc251372c63f6dfdd5dd5a0f9046d9fecd8e (diff) |
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.
Diffstat (limited to 'nixos/modules/services/networking/epmd.nix')
-rw-r--r-- | nixos/modules/services/networking/epmd.nix | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/epmd.nix b/nixos/modules/services/networking/epmd.nix new file mode 100644 index 000000000000..692b75e4f086 --- /dev/null +++ b/nixos/modules/services/networking/epmd.nix @@ -0,0 +1,56 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.epmd; + +in + +{ + ###### interface + options.services.epmd = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable socket activation for Erlang Port Mapper Daemon (epmd), + which acts as a name server on all hosts involved in distributed + Erlang computations. + ''; + }; + package = mkOption { + type = types.package; + default = pkgs.erlang; + description = '' + The Erlang package to use to get epmd binary. That way you can re-use + an Erlang runtime that is already installed for other purposes. + ''; + }; + }; + + ###### implementation + config = mkIf cfg.enable { + systemd.sockets.epmd = rec { + description = "Erlang Port Mapper Daemon Activation Socket"; + wantedBy = [ "sockets.target" ]; + before = wantedBy; + socketConfig = { + ListenStream = "4369"; + Accept = "false"; + }; + }; + + systemd.services.epmd = { + description = "Erlang Port Mapper Daemon"; + after = [ "network.target" ]; + requires = [ "epmd.socket" ]; + + serviceConfig = { + DynamicUser = true; + ExecStart = "${cfg.package}/bin/epmd -systemd"; + Type = "notify"; + }; + }; + }; +} |