From 420f522dfaf3cb15e18db8e9602d296c4d460738 Mon Sep 17 00:00:00 2001 From: illustris Date: Wed, 5 Jan 2022 18:40:39 +0530 Subject: [PATCH] nixos/elasticsearch: fix crashes on large datanodes https://github.com/NixOS/nixpkgs/commit/3a1e1f062432fbc867502187972b37f7a6f9fe63 adds a poststart script that checks if ES successfully started by curling the HTTP endpoint. On nodes with a lot of data or slower disks, this might take longer than the default systemd startup timeout of 90 seconds. --- nixos/modules/services/search/elasticsearch.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nixos/modules/services/search/elasticsearch.nix b/nixos/modules/services/search/elasticsearch.nix index 6df147be0c49..307bfee22385 100644 --- a/nixos/modules/services/search/elasticsearch.nix +++ b/nixos/modules/services/search/elasticsearch.nix @@ -143,6 +143,17 @@ in example = lib.literalExpression "[ pkgs.elasticsearchPlugins.discovery-ec2 ]"; }; + restartIfChanged = mkOption { + type = types.bool; + description = '' + Automatically restart the service on config change. + This can be set to false to defer restarts on a server or cluster. + Please consider the security implications of inadvertently running an older version, + and the possibility of unexpected behavior caused by inconsistent versions across a cluster when disabling this option. + ''; + default = true; + }; + }; ###### implementation @@ -153,6 +164,7 @@ in wantedBy = [ "multi-user.target" ]; after = [ "network.target" ]; path = [ pkgs.inetutils ]; + inherit (cfg) restartIfChanged; environment = { ES_HOME = cfg.dataDir; ES_JAVA_OPTS = toString cfg.extraJavaOptions; @@ -163,6 +175,8 @@ in User = "elasticsearch"; PermissionsStartOnly = true; LimitNOFILE = "1024000"; + Restart = "always"; + TimeoutStartSec = "infinity"; }; preStart = '' ${optionalString (!config.boot.isContainer) ''