From 2592b82c313ef7ea4eb60a244b24f75cae4af3fe Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 3 Dec 2019 15:02:47 +0100 Subject: [PATCH] Try harder to restart ldap, if it's failing In case it won't restart, restart all zimbra services, prevents mailboxd going crasy and filling GB of logs about not being able to contact LDAP --- zmbh/zmbh.pl | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/zmbh/zmbh.pl b/zmbh/zmbh.pl index 38e9246..61c3d17 100644 --- a/zmbh/zmbh.pl +++ b/zmbh/zmbh.pl @@ -101,7 +101,24 @@ if ( $opt->{pre} ) { log_info("No service were shutted down"); } elsif ($opt->{shutdown} eq 'ldap' and -e '/opt/zimbra/bin/ldap'){ log_info("Starting Zimbra LDAP service"); - system("/opt/zimbra/bin/ldap start"); + my $try = 0; + my $running = 0; + while ($try < 20) { + system("/opt/zimbra/bin/ldap start"); + sleep 1; + if (system("/opt/zimbra/bin/ldap status") == 0){ + $running = 1; + last; + } else { + log_info('ldap service not running, trying again to start it'); + $try++; + } + } + # Couldn't start ldap ? Restart all the services + if (not $running){ + log_info("Failed to restart ldap, restarting all Zimbra services"); + system('systemctl restart zimbra'); + } } else { log_info("Starting Zimbra services"); system('systemctl start zimbra');