From 9126b18d8bbf7d8f0f8981deb84f80f2eaa27bfe Mon Sep 17 00:00:00 2001 From: Martin Kosek Date: Thu, 18 Oct 2012 16:50:08 +0200 Subject: 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 --- ipapython/platform/redhat.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'ipapython/platform') 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): -- cgit