Fix check-ldap slapd start race
We start slapd in the foreground (-d0) but backgrounded in the shell, then we wait 4 seconds. This causes a race condition however. This commit makes the slapd-init script more robust and limits the wait to however many seconds (up to 30) that slapd needs to start service.
This commit is contained in:

committed by
Nico Williams

parent
65ed504d21
commit
e93a135765
@@ -44,5 +44,15 @@ cp "`which slapd`" . || true # fails if running
|
|||||||
|
|
||||||
echo "starting slapd"
|
echo "starting slapd"
|
||||||
./slapd -d0 -f "${srcdir}/slapd.conf" -h ldapi://.%2Fldap-socket &
|
./slapd -d0 -f "${srcdir}/slapd.conf" -h ldapi://.%2Fldap-socket &
|
||||||
|
slapd_pid=$!
|
||||||
|
|
||||||
sleep 4
|
tries=0
|
||||||
|
while kill -0 $slapd_pid && [ ! -S ldap-socket ] &&
|
||||||
|
! ldapsearch -l 2 -w '' -D '' -b "o=TEST,dc=H5L,dc=SE" -s base -H ldapi://.%2Fldap-socket >/dev/null &&
|
||||||
|
[ $tries -lt 30 ]; do
|
||||||
|
sleep 1
|
||||||
|
tries=`expr 1 + $tries`
|
||||||
|
done
|
||||||
|
|
||||||
|
kill -0 $slapd_pid || exit 1
|
||||||
|
[ -S ldap-socket ] || exit 1
|
||||||
|
Reference in New Issue
Block a user