nixos/elasticsearch: Wait for elasticsearch to start up properly

Other services that depend on elasticsearch should be started after
it, but since the versions we're packaging have to run as
"Type=simple", they're started as soon as the elasticsearch binary has
been executed, likely winning the race against it.

This makes sure elasticsearch is up and running, responding to a
simple query, before dependents are started.

talyz 3a1e1f06 5c61b9f3

Changed files
+7
nixos
modules
services
+7
nixos/modules/services/search/elasticsearch.nix
···
if [ "$(id -u)" = 0 ]; then chown -R elasticsearch:elasticsearch ${cfg.dataDir}; fi
'';
+
postStart = ''
+
# Make sure elasticsearch is up and running before dependents
+
# are started
+
while ! ${pkgs.curl}/bin/curl -sS -f http://localhost:${toString cfg.port} 2>/dev/null; do
+
sleep 1
+
done
+
'';
};
environment.systemPackages = [ cfg.package ];