def _start_stop_reload(self, action): ''' XXX: Temporary ugly hack (Ubuntu 1004 upstart problem - Job is already running)''' args = [self.initd_script] \ if isinstance(self.initd_script, basestring) \ else list(self.initd_script) args.append(action) # SCALARIZR-1851 debug { #env = os.environ.copy() #env['DEBIAN_SCRIPT_DEBUG'] = '1' # } out, err, returncode = system2(args, close_fds=True, preexec_fn=os.setsid, raise_exc=False) if returncode and ( \ 'Job is already running' not in err and \ 'percona' not in node.__node__['behavior']): raise InitdError("Popen failed with error: %s" % (err, )) if action == 'restart': if err and 'stop: Job has already been stopped: mysql' in err: return True else: LOG.debug('waiting for mysql process') wait_until(lambda: MYSQLD_PATH in system2( ('ps', '-G', DEFAULT_OWNER, '-o', 'command', '--no-headers' ))[0], timeout=10, sleep=1) if action == 'start' and linux.os.ubuntu and linux.os['version'] >= ( 10, 4): try: LOG.debug('waiting for mysql process') wait_until(lambda: MYSQLD_PATH in system2( ('ps', '-G', DEFAULT_OWNER, '-o', 'command', '--no-headers' ))[0], timeout=10, sleep=1) LOG.debug('waiting for debian-start finish') out = system2( 'ps axo pid,command --noheaders | grep /etc/mysql/debian-start', shell=True)[0].strip() if out: pid = out.split('\n')[0].split(' ')[0] wait_until(lambda: not os.path.exists('/proc/%s' % pid), sleep=1) except: self._start_stop_reload('restart') return True if self.socks and (action != "stop" and not (action == 'reload' and not self.running)): for sock in self.socks: wait_sock(sock) return True
def reload(self, reason=None): if self.running: LOG.info("Reloading apache: %s" % str(reason) if reason else '') try: out, err, retcode = system2(__apache__["apachectl"] + " graceful", shell=True) if retcode > 0: raise initdv2.InitdError("Cannot reload apache: %s" % err) except PopenError, e: raise InitdError(e)
def configtest(self, path=None): args = __apache__["apachectl"] + " configtest" if path: args += "-f %s" % path try: out = system2(args, shell=True)[1] if "error" in out.lower(): raise initdv2.InitdError("Invalid Apache configuration: %s" % out) except PopenError, e: raise InitdError(e)
def _start_stop_reload(self, action): ''' XXX: Temporary ugly hack (Ubuntu 1004 upstart problem - Job is already running)''' try: args = [self.initd_script] \ if isinstance(self.initd_script, basestring) \ else list(self.initd_script) args.append(action) out, err, returncode = system2(args, close_fds=True, preexec_fn=os.setsid) except PopenError, e: if 'Job is already running' not in str(e): raise InitdError("Popen failed with error %s" % (e, ))
self.pid_file) time.sleep(0.5) def reload(self, reason=None): if self.running: LOG.info("Reloading apache: %s" % str(reason) if reason else '') try: out, err, retcode = system2(__apache__["apachectl"] + " graceful", shell=True) if retcode > 0: raise initdv2.InitdError("Cannot reload apache: %s" % err) except PopenError, e: raise InitdError(e) else: raise InitdError("Service '%s' is not running" % self.name, InitdError.NOT_RUNNING) @staticmethod def _main_process_started(): res = False try: out = system2(("ps", "-G", __apache__["group"], "-o", "command", "--no-headers"), raise_exc=False)[0] res = __apache__["bin_path"] in out except (Exception, BaseException): pass return res initdv2.explore("apache", ApacheInitScript)