Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 | 37 |
| 38 _log = logging.getLogger(__name__) | 38 _log = logging.getLogger(__name__) |
| 39 | 39 |
| 40 | 40 |
| 41 class ApacheHTTP(server_base.ServerBase): | 41 class ApacheHTTP(server_base.ServerBase): |
| 42 def __init__(self, port_obj, output_dir, additional_dirs, number_of_servers) : | 42 def __init__(self, port_obj, output_dir, additional_dirs, number_of_servers) : |
| 43 super(ApacheHTTP, self).__init__(port_obj, output_dir) | 43 super(ApacheHTTP, self).__init__(port_obj, output_dir) |
| 44 # We use the name "httpd" instead of "apache" to make our paths (e.g. th e pid file: /tmp/WebKit/httpd.pid) | 44 # We use the name "httpd" instead of "apache" to make our paths (e.g. th e pid file: /tmp/WebKit/httpd.pid) |
| 45 # match old-run-webkit-tests: https://bugs.webkit.org/show_bug.cgi?id=63 956 | 45 # match old-run-webkit-tests: https://bugs.webkit.org/show_bug.cgi?id=63 956 |
| 46 self._name = 'httpd' | 46 self._name = 'httpd' |
| 47 self._log_prefixes = ('access_log', 'error_log') | |
|
Dirk Pranke
2014/07/23 23:21:11
The fact that this line was missing means that we
| |
| 47 self._mappings = [{'port': 8000}, | 48 self._mappings = [{'port': 8000}, |
| 48 {'port': 8080}, | 49 {'port': 8080}, |
| 49 {'port': 8443, 'sslcert': True}] | 50 {'port': 8443, 'sslcert': True}] |
| 50 self._number_of_servers = number_of_servers | 51 self._number_of_servers = number_of_servers |
| 51 | 52 |
| 52 self._pid_file = self._filesystem.join(self._runtime_path, '%s.pid' % se lf._name) | 53 self._pid_file = self._filesystem.join(self._runtime_path, '%s.pid' % se lf._name) |
| 53 | 54 |
| 54 executable = self._port_obj.path_to_apache() | 55 executable = self._port_obj.path_to_apache() |
| 55 server_root = self._filesystem.dirname(self._filesystem.dirname(executab le)) | 56 server_root = self._filesystem.dirname(self._filesystem.dirname(executab le)) |
| 56 | 57 |
| 57 test_dir = self._port_obj.layout_tests_dir() | 58 test_dir = self._port_obj.layout_tests_dir() |
| 58 document_root = self._filesystem.join(test_dir, "http", "tests") | 59 document_root = self._filesystem.join(test_dir, "http", "tests") |
| 59 js_test_resources_dir = self._filesystem.join(test_dir, "resources") | 60 js_test_resources_dir = self._filesystem.join(test_dir, "resources") |
| 60 media_resources_dir = self._filesystem.join(test_dir, "media") | 61 media_resources_dir = self._filesystem.join(test_dir, "media") |
| 61 mime_types_path = self._filesystem.join(test_dir, "http", "conf", "mime. types") | 62 mime_types_path = self._filesystem.join(test_dir, "http", "conf", "mime. types") |
| 62 cert_file = self._filesystem.join(test_dir, "http", "conf", "webkit-http d.pem") | 63 cert_file = self._filesystem.join(test_dir, "http", "conf", "webkit-http d.pem") |
| 63 | 64 |
| 64 access_log = self._filesystem.join(output_dir, "access_log.txt") | 65 self._access_log = self._filesystem.join(output_dir, "access_log.txt") |
| 65 error_log = self._filesystem.join(output_dir, "error_log.txt") | 66 self._error_log = self._filesystem.join(output_dir, "error_log.txt") |
| 66 | 67 |
| 67 self._is_win = self._port_obj.host.platform.is_win() | 68 self._is_win = self._port_obj.host.platform.is_win() |
| 68 | 69 |
| 69 start_cmd = [executable, | 70 start_cmd = [executable, |
| 70 '-f', '%s' % self._port_obj.path_to_apache_config_file(), | 71 '-f', '%s' % self._port_obj.path_to_apache_config_file(), |
| 71 '-C', 'ServerRoot "%s"' % server_root, | 72 '-C', 'ServerRoot "%s"' % server_root, |
| 72 '-C', 'DocumentRoot "%s"' % document_root, | 73 '-C', 'DocumentRoot "%s"' % document_root, |
| 73 '-c', 'Alias /js-test-resources "%s"' % js_test_resources_dir, | 74 '-c', 'Alias /js-test-resources "%s"' % js_test_resources_dir, |
| 74 '-c', 'Alias /media-resources "%s"' % media_resources_dir, | 75 '-c', 'Alias /media-resources "%s"' % media_resources_dir, |
| 75 '-c', 'TypesConfig "%s"' % mime_types_path, | 76 '-c', 'TypesConfig "%s"' % mime_types_path, |
| 76 '-c', 'CustomLog "%s" common' % access_log, | 77 '-c', 'CustomLog "%s" common' % self._access_log, |
| 77 '-c', 'ErrorLog "%s"' % error_log, | 78 '-c', 'ErrorLog "%s"' % self._error_log, |
| 78 '-c', 'PidFile %s' % self._pid_file, | 79 '-c', 'PidFile %s' % self._pid_file, |
| 79 '-c', 'SSLCertificateFile "%s"' % cert_file, | 80 '-c', 'SSLCertificateFile "%s"' % cert_file, |
| 80 ] | 81 ] |
| 81 | 82 |
| 82 if self._is_win: | 83 if self._is_win: |
| 83 start_cmd += ['-c', "ThreadsPerChild %d" % (self._number_of_servers * 2)] | 84 start_cmd += ['-c', "ThreadsPerChild %d" % (self._number_of_servers * 2)] |
| 84 else: | 85 else: |
| 85 start_cmd += ['-c', "StartServers %d" % self._number_of_servers, | 86 start_cmd += ['-c', "StartServers %d" % self._number_of_servers, |
| 86 '-c', "MinSpareServers %d" % self._number_of_servers, | 87 '-c', "MinSpareServers %d" % self._number_of_servers, |
| 87 '-c', "MaxSpareServers %d" % self._number_of_servers, | 88 '-c', "MaxSpareServers %d" % self._number_of_servers, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 118 start_cmd += ['-c', 'Alias %s "%s"' % (alias, path), | 119 start_cmd += ['-c', 'Alias %s "%s"' % (alias, path), |
| 119 # Disable CGI handler for additional dirs. | 120 # Disable CGI handler for additional dirs. |
| 120 '-c', '<Location %s>' % alias, | 121 '-c', '<Location %s>' % alias, |
| 121 '-c', 'RemoveHandler .cgi .pl', | 122 '-c', 'RemoveHandler .cgi .pl', |
| 122 '-c', '</Location>'] | 123 '-c', '</Location>'] |
| 123 | 124 |
| 124 self._start_cmd = start_cmd | 125 self._start_cmd = start_cmd |
| 125 | 126 |
| 126 def _spawn_process(self): | 127 def _spawn_process(self): |
| 127 _log.debug('Starting %s server, cmd="%s"' % (self._name, str(self._start _cmd))) | 128 _log.debug('Starting %s server, cmd="%s"' % (self._name, str(self._start _cmd))) |
| 128 self._process = self._executive.popen(self._start_cmd) | 129 self._process = self._executive.popen(self._start_cmd, stderr=self._exec utive.PIPE) |
|
Dirk Pranke
2014/07/23 23:21:11
This being missing meant that stderr logging was g
| |
| 129 if self._process.returncode is not None: | 130 if self._process.returncode is not None: |
| 130 retval = self._process.returncode | 131 retval = self._process.returncode |
| 131 err = self._process.stderr.read() | 132 err = self._process.stderr.read() |
| 132 if retval or len(err): | 133 if retval or len(err): |
| 133 raise server_base.ServerError('Failed to start %s: %s' % (self._ name, err)) | 134 raise server_base.ServerError('Failed to start %s: %s' % (self._ name, err)) |
| 134 | 135 |
| 135 # For some reason apache isn't guaranteed to have created the pid file b efore | 136 # For some reason apache isn't guaranteed to have created the pid file b efore |
| 136 # the process exits, so we wait a little while longer. | 137 # the process exits, so we wait a little while longer. |
| 137 if not self._wait_for_action(lambda: self._filesystem.exists(self._pid_f ile)): | 138 if not self._wait_for_action(lambda: self._filesystem.exists(self._pid_f ile)): |
| 139 self._dump_logs() | |
| 138 raise server_base.ServerError('Failed to start %s: no pid file found ' % self._name) | 140 raise server_base.ServerError('Failed to start %s: no pid file found ' % self._name) |
| 139 | 141 |
| 140 return int(self._filesystem.read_text_file(self._pid_file)) | 142 return int(self._filesystem.read_text_file(self._pid_file)) |
| 141 | 143 |
| 142 def stop(self): | 144 def stop(self): |
| 143 self._stop_running_server() | 145 self._stop_running_server() |
| 144 | 146 |
| 145 def _stop_running_server(self): | 147 def _stop_running_server(self): |
| 146 # If apache was forcefully killed, the pid file will not have been delet ed, so check | 148 # If apache was forcefully killed, the pid file will not have been delet ed, so check |
| 147 # that the process specified by the pid_file no longer exists before del eting the file. | 149 # that the process specified by the pid_file no longer exists before del eting the file. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 161 retval = proc.returncode | 163 retval = proc.returncode |
| 162 err = proc.stderr.read() | 164 err = proc.stderr.read() |
| 163 if retval or len(err): | 165 if retval or len(err): |
| 164 raise server_base.ServerError('Failed to stop %s: %s' % (self._name, err)) | 166 raise server_base.ServerError('Failed to stop %s: %s' % (self._name, err)) |
| 165 | 167 |
| 166 # For some reason apache isn't guaranteed to have actually stopped after | 168 # For some reason apache isn't guaranteed to have actually stopped after |
| 167 # the stop command returns, so we wait a little while longer for the | 169 # the stop command returns, so we wait a little while longer for the |
| 168 # pid file to be removed. | 170 # pid file to be removed. |
| 169 if not self._wait_for_action(lambda: not self._filesystem.exists(self._p id_file)): | 171 if not self._wait_for_action(lambda: not self._filesystem.exists(self._p id_file)): |
| 170 raise server_base.ServerError('Failed to stop %s: pid file still exi sts' % self._name) | 172 raise server_base.ServerError('Failed to stop %s: pid file still exi sts' % self._name) |
| OLD | NEW |