def _stop_running_server(self): # If apache was forcefully killed, the pid file will not have been deleted, so check # that the process specified by the pid_file no longer exists before deleting the file. if self._pid and not self._executive.check_running_pid(self._pid): self._filesystem.remove(self._pid_file) return if self._is_win: self._executive.kill_process(self._pid) return proc = self._executive.popen([ self._port_obj.path_to_apache(), '-f', self._port_obj.path_to_apache_config_file(), '-c', 'PidFile "%s"' % self._pid_file, '-k', 'stop' ], stderr=self._executive.PIPE) proc.wait() retval = proc.returncode err = proc.stderr.read() if retval or len(err): raise server_base.ServerError('Failed to stop %s: %s' % (self._name, err)) # For some reason apache isn't guaranteed to have actually stopped after # the stop command returns, so we wait a little while longer for the # pid file to be removed. if not self._wait_for_action( lambda: not self._filesystem.exists(self._pid_file)): raise server_base.ServerError( 'Failed to stop %s: pid file still exists' % self._name)
def _spawn_process(self): _log.debug('Starting %s server, cmd="%s"', self._name, str(self._start_cmd)) self._process = self._executive.popen(self._start_cmd) retval = self._process.returncode if retval: raise server_base.ServerError('Failed to start %s: %s' % (self._name, retval)) # For some reason apache isn't guaranteed to have created the pid file before # the process exits, so we wait a little while longer. if not self._wait_for_action(lambda: self._filesystem.exists(self._pid_file)): self._log_errors_from_subprocess() raise server_base.ServerError('Failed to start %s: no pid file found' % self._name) return int(self._filesystem.read_text_file(self._pid_file))