From 412fa16bffcb915f796e95b12281bc568be7c1ae Mon Sep 17 00:00:00 2001 From: Kranium Gikos Date: Mon, 25 Sep 2017 00:37:17 +1000 Subject: [PATCH] influxdb sevice: make postStart test work with non-localhost configurations (#29734) make postStart test work with non-localhost configurations --- nixos/modules/services/databases/influxdb.nix | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/databases/influxdb.nix b/nixos/modules/services/databases/influxdb.nix index eeab33309fda..15b711f57b13 100644 --- a/nixos/modules/services/databases/influxdb.nix +++ b/nixos/modules/services/databases/influxdb.nix @@ -170,11 +170,16 @@ in mkdir -m 0770 -p ${cfg.dataDir} if [ "$(id -u)" = 0 ]; then chown -R ${cfg.user}:${cfg.group} ${cfg.dataDir}; fi ''; - postStart = mkBefore '' - until ${pkgs.curl.bin}/bin/curl -s -o /dev/null ${if configOptions.http.https-enabled then "-k https" else "http"}://127.0.0.1${toString configOptions.http.bind-address}/ping; do - sleep 1; - done - ''; + postStart = + let + scheme = if configOptions.http.https-enabled then "-k https" else "http"; + bindAddr = (ba: if hasPrefix ":" ba then "127.0.0.1${ba}" else "${ba}")(toString configOptions.http.bind-address); + in + mkBefore '' + until ${pkgs.curl.bin}/bin/curl -s -o /dev/null ${scheme}://${bindAddr}/ping; do + sleep 1; + done + ''; }; users.extraUsers = optional (cfg.user == "influxdb") {