influxdb sevice: make postStart test work with non-localhost configurations (#29734)

make postStart test work with non-localhost configurations

authored by Kranium Gikos and committed by zimbatm.tngl.sh 412fa16b 5fa6b341

+10 -5
+10 -5
nixos/modules/services/databases/influxdb.nix
··· 170 170 mkdir -m 0770 -p ${cfg.dataDir} 171 171 if [ "$(id -u)" = 0 ]; then chown -R ${cfg.user}:${cfg.group} ${cfg.dataDir}; fi 172 172 ''; 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 + ''; 178 183 }; 179 184 180 185 users.extraUsers = optional (cfg.user == "influxdb") {