| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Start and stop the WPTserve servers as they're used by the layout tests.""" | 5 """Start and stop the WPTserve servers as they're used by the layout tests.""" |
| 6 | 6 |
| 7 import datetime | 7 import datetime |
| 8 import logging | 8 import logging |
| 9 |
| 9 from webkitpy.layout_tests.servers import server_base | 10 from webkitpy.layout_tests.servers import server_base |
| 10 | 11 |
| 11 | 12 |
| 13 _log = logging.getLogger(__name__) |
| 14 |
| 15 |
| 12 class WPTServe(server_base.ServerBase): | 16 class WPTServe(server_base.ServerBase): |
| 13 | 17 |
| 14 def __init__(self, port_obj, output_dir): | 18 def __init__(self, port_obj, output_dir): |
| 15 super(WPTServe, self).__init__(port_obj, output_dir) | 19 super(WPTServe, self).__init__(port_obj, output_dir) |
| 16 # These ports must match wpt_support/wpt.config.json | 20 # These ports must match wpt_support/wpt.config.json |
| 17 http_port, http_alt_port, https_port = (8001, 8081, 8444) | 21 http_port, http_alt_port, https_port = (8001, 8081, 8444) |
| 18 ws_port, wss_port = (9001, 9444) | 22 ws_port, wss_port = (9001, 9444) |
| 19 self._name = 'wptserve' | 23 self._name = 'wptserve' |
| 20 self._log_prefixes = ('access_log', 'error_log') | 24 self._log_prefixes = ('access_log', 'error_log') |
| 21 self._mappings = [{'port': http_port}, | 25 self._mappings = [{'port': http_port}, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 50 self._env = port_obj.host.environ.copy() | 54 self._env = port_obj.host.environ.copy() |
| 51 self._env.update({'PYTHONPATH': path_to_thirdparty}) | 55 self._env.update({'PYTHONPATH': path_to_thirdparty}) |
| 52 self._start_cmd = start_cmd | 56 self._start_cmd = start_cmd |
| 53 | 57 |
| 54 expiration_date = datetime.date(2025, 1, 4) | 58 expiration_date = datetime.date(2025, 1, 4) |
| 55 if datetime.date.today() > expiration_date - datetime.timedelta(30): | 59 if datetime.date.today() > expiration_date - datetime.timedelta(30): |
| 56 logging.getLogger(__name__).error( | 60 logging.getLogger(__name__).error( |
| 57 'Pre-generated keys and certificates are going to be expired at
%s.' | 61 'Pre-generated keys and certificates are going to be expired at
%s.' |
| 58 ' Please re-generate them by following steps in %s/README.chromi
um.' | 62 ' Please re-generate them by following steps in %s/README.chromi
um.' |
| 59 % (expiration_date.strftime('%b %d %Y'), path_to_wpt_support)) | 63 % (expiration_date.strftime('%b %d %Y'), path_to_wpt_support)) |
| 64 |
| 65 def _stop_running_server(self): |
| 66 self._wait_for_action(self._check_and_kill_wptserve) |
| 67 if self._filesystem.exists(self._pid_file): |
| 68 self._filesystem.remove(self._pid_file) |
| 69 |
| 70 def _check_and_kill_wptserve(self): |
| 71 """Tries to kill wptserve. |
| 72 |
| 73 Returns True if it appears to be not running. Or, if it appears to be |
| 74 running, tries to kill the process and returns False. |
| 75 """ |
| 76 if not (self._pid and self._executive.check_running_pid(self._pid)): |
| 77 _log.debug('pid %d is not running', self._pid) |
| 78 return True |
| 79 |
| 80 _log.debug('pid %d is running, killing it', self._pid) |
| 81 |
| 82 # Executive.kill_process appears to not to effectively kill the |
| 83 # wptserve processes on Linux (and presumably other platforms). |
| 84 if self._platform.is_win(): |
| 85 self._executive.kill_process(self._pid) |
| 86 else: |
| 87 self._executive.interrupt(self._pid) |
| 88 |
| 89 # According to Popen.wait(), this can deadlock when using stdout=PIPE or |
| 90 # stderr=PIPE. We're using DEVNULL for both so that should not occur. |
| 91 if self._process is not None: |
| 92 self._process.wait() |
| 93 |
| 94 return False |
| OLD | NEW |