Пример #1
0
    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._port_obj.host.platform.is_win(
        ) and not self._executive.check_running_pid(self._pid):
            self._filesystem.remove(self._pid_file)
            return

        retval, err = self._run(self._stop_cmd)

        # Windows httpd outputs shutdown status in stderr:
        if self._port_obj.host.platform.is_win() and not retval and len(err):
            _log.debug('Shutdown: %s' % err)
            err = ""

        if retval or len(err):
            raise http_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)):
            if self._port_obj.host.platform.is_win():
                self._remove_pid_file()
                return

            raise http_server_base.ServerError(
                'Failed to stop %s: pid file still exists' % self._name)
Пример #2
0
    def _spawn_process(self):
        _log.debug('Starting %s server, cmd="%s"' % (self._name, str(self._start_cmd)))
        retval, err = self._run(self._start_cmd)
        if retval or len(err):
            raise http_server_base.ServerError('Failed to start %s: %s' % (self._name, err))

        # 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)):
            raise http_server_base.ServerError('Failed to start %s: no pid file found' % self._name)

        return int(self._filesystem.read_text_file(self._pid_file))
Пример #3
0
    def _stop_running_server(self):
        retval, err = self._run(self._stop_cmd)
        if retval or len(err):
            raise http_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 http_server_base.ServerError(
                'Failed to stop %s: pid file still exists' % self._name)
Пример #4
0
    def _spawn_process(self):
        self._process = self._executive.popen(self._start_cmd,
                                              cwd=self._doc_root_path,
                                              shell=False,
                                              stdin=self._executive.PIPE,
                                              stdout=self._wsout,
                                              stderr=self._wsout)
        self._filesystem.write_text_file(self._pid_file,
                                         str(self._process.pid))

        # Wait a second for the server to actually start so that tests do not start until server is running.
        time.sleep(1)

        # The server is not running after 1 second, something went wrong.
        if self._process.poll() is not None:
            self._stop_running_server()
            error_log = (
                'WPT Server process exited prematurely with status code %s\n' %
                self._process.returncode +
                'The cmdline for running the WPT server was: %s\n' %
                self._start_cmd +
                'The working dir was: %s\n' % self._doc_root_path)
            if self._output_log_path is not None and self._filesystem.exists(
                    self._output_log_path):
                error_log += 'Check the logfile for the command at: %s\n' % self._output_log_path
            raise http_server_base.ServerError(error_log)

        return self._process.pid
Пример #5
0
    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

        retval, err = self._run(self._stop_cmd)
        if retval or len(err):
            raise http_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 http_server_base.ServerError('Failed to stop %s: pid file still exists' % self._name)
Пример #6
0
 def _server_error(self, message, stderr_output, exit_code):
     if self.platform.is_win() and exit_code == 720005 and not stderr_output:
         stderr_output = 'Access is denied. Do you have administrator privilege?'
     return http_server_base.ServerError('{}: {} (exit code={})'.format(message, stderr_output, exit_code))