influxdb sevice: make postStart test work with non-localhost configurations (#29734)
make postStart test work with non-localhost configurations
commit412fa16bffcb915f796e95b12281bc568be7c1ae
authorKranium Gikos <kranium@gikos.net>
dateMon 25 Sep 2017, 00:37 (9 years ago)
parent5fa6b34
nixos/modules/services/databases/influxdb.nix+10−5
@@ -170,11 +170,16 @@ in
170170 mkdir -m 0770 -p ${cfg.dataDir}
171171 if [ "$(id -u)" = 0 ]; then chown -R ${cfg.user}:${cfg.group} ${cfg.dataDir}; fi
172172 '';
173− postStart = mkBefore ''
174− 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
175− sleep 1;
176− done
177− '';
173+ postStart =
174+ let
175+ scheme = if configOptions.http.https-enabled then "-k https" else "http";
176+ bindAddr = (ba: if hasPrefix ":" ba then "127.0.0.1${ba}" else "${ba}")(toString configOptions.http.bind-address);
177+ in
178+ mkBefore ''
179+ until ${pkgs.curl.bin}/bin/curl -s -o /dev/null ${scheme}://${bindAddr}/ping; do
180+ sleep 1;
181+ done
182+ '';
178183 };
179184
180185 users.extraUsers = optional (cfg.user == "influxdb") {