summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2012-10-18 16:50:08 +0200
committerRob Crittenden <rcritten@redhat.com>2012-10-18 20:53:42 -0400
commit9126b18d8bbf7d8f0f8981deb84f80f2eaa27bfe (patch)
tree4f564ad1344b1ac711f3339304a06ba3a4629552
parent62cce242247243e9656b10f587a31ed0459899ac (diff)
Add fallback for httpd restarts on sysV platforms
httpd init script on sysV based platforms cannot guarantee that two consecutive httpd service restarts succeed when run in a small time distance. Add fallback procedure that adds additional waiting time after such failed restart attempt, and then try to stop and start the service again. https://fedorahosted.org/freeipa/ticket/2965
-rw-r--r--ipapython/platform/redhat.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/ipapython/platform/redhat.py b/ipapython/platform/redhat.py
index 3f35cfcc9..3551c2841 100644
--- a/ipapython/platform/redhat.py
+++ b/ipapython/platform/redhat.py
@@ -25,9 +25,11 @@ import stat
import sys
import socket
import stat
+import time
from ipapython import ipautil
from ipapython.platform import base
+from ipapython.ipa_log_manager import root_logger
from ipalib import api
# All what we allow exporting directly from this module
@@ -115,6 +117,19 @@ class RedHatSSHService(RedHatService):
def get_config_dir(self, instance_name=""):
return '/etc/ssh'
+class RedHatHTTPDService(RedHatService):
+ def restart(self, instance_name="", capture_output=True, wait=True):
+ try:
+ super(RedHatHTTPDService, self).restart(instance_name, capture_output, wait)
+ except ipautil.CalledProcessError:
+ # http may have issues with binding to ports, try to fallback
+ # https://bugzilla.redhat.com/show_bug.cgi?id=845405
+ root_logger.debug("%s restart failed, try to stop&start again", self.service_name)
+ time.sleep(5)
+ self.stop(instance_name, capture_output)
+ time.sleep(5)
+ self.start(instance_name, capture_output, wait)
+
class RedHatAuthConfig(base.AuthConfig):
"""
AuthConfig class implements system-independent interface to configure
@@ -145,6 +160,8 @@ class RedHatAuthConfig(base.AuthConfig):
def redhat_service(name):
if name == 'sshd':
return RedHatSSHService(name)
+ elif name == 'httpd':
+ return RedHatHTTPDService(name)
return RedHatService(name)
class RedHatServices(base.KnownServices):