Make nscd startup synchronous

Nscd forks into the background before it's ready to accept
connections. So explicitly wait until it's ready.

http://hydra.nixos.org/build/10661767
This commit is contained in:
Eelco Dolstra 2014-04-24 23:15:39 +02:00
parent d7a7f80aff
commit 23297b0edd
2 changed files with 14 additions and 3 deletions

View file

@ -9,6 +9,8 @@ let
inherit (pkgs.lib) singleton;
cfgFile = pkgs.writeText "nscd.conf" cfg.config;
in
{
@ -63,7 +65,7 @@ in
restartTriggers = [ config.environment.etc.hosts.source ];
serviceConfig =
{ ExecStart = "@${pkgs.glibc}/sbin/nscd nscd -f ${pkgs.writeText "nscd.conf" cfg.config}";
{ ExecStart = "@${pkgs.glibc}/sbin/nscd nscd -f ${cfgFile}";
Type = "forking";
PIDFile = "/run/nscd/nscd.pid";
Restart = "always";
@ -73,6 +75,15 @@ in
"${pkgs.glibc}/sbin/nscd --invalidate hosts"
];
};
# Urgggggh... Nscd forks before opening its socket and writing
# its pid. So wait until it's ready.
postStart =
''
while ! ${pkgs.glibc}/sbin/nscd -g -f ${cfgFile} > /dev/null; do
sleep 0.2
done
'';
};
};

View file

@ -13,6 +13,8 @@ import ./make-test.nix {
testScript =
''
$machine->waitForUnit("default.target");
subtest "nixos-version", sub {
$machine->succeed("[ `nixos-version | wc -w` = 2 ]");
};
@ -61,8 +63,6 @@ import ./make-test.nix {
# Test whether hostname (and by extension nss_myhostname) works.
subtest "hostname", sub {
$machine->waitForUnit("dhcpcd.service");
$machine->waitForUnit("network.target");
$machine->succeed('[ "`hostname`" = machine ]');
$machine->succeed('[ "`hostname -s`" = machine ]');
};