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 21 matching lines...) Expand all Loading... |
32 import os | 32 import os |
33 import socket | 33 import socket |
34 | 34 |
35 from webkitpy.layout_tests.servers import server_base | 35 from webkitpy.layout_tests.servers import server_base |
36 | 36 |
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 |
42 def __init__(self, port_obj, output_dir, additional_dirs, number_of_servers)
: | 43 def __init__(self, port_obj, output_dir, additional_dirs, number_of_servers)
: |
43 super(ApacheHTTP, self).__init__(port_obj, output_dir) | 44 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) | 45 # 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 | 46 # match old-run-webkit-tests: https://bugs.webkit.org/show_bug.cgi?id=63
956 |
46 self._name = 'httpd' | 47 self._name = 'httpd' |
47 self._log_prefixes = ('access_log', 'error_log') | 48 self._log_prefixes = ('access_log', 'error_log') |
48 self._mappings = [{'port': 8000}, | 49 self._mappings = [{'port': 8000}, |
49 {'port': 8080}, | 50 {'port': 8080}, |
50 {'port': 8443, 'sslcert': True}] | 51 {'port': 8443, 'sslcert': True}] |
51 self._number_of_servers = number_of_servers | 52 self._number_of_servers = number_of_servers |
(...skipping 24 matching lines...) Expand all Loading... |
76 '-C', 'DocumentRoot "%s"' % document_root, | 77 '-C', 'DocumentRoot "%s"' % document_root, |
77 '-c', 'Alias /js-test-resources "%s"' % js_test_resources_dir, | 78 '-c', 'Alias /js-test-resources "%s"' % js_test_resources_dir, |
78 '-c', 'Alias /forms-test-resources "%s"' % forms_test_resources_dir, | 79 '-c', 'Alias /forms-test-resources "%s"' % forms_test_resources_dir, |
79 '-c', 'Alias /media-resources "%s"' % media_resources_dir, | 80 '-c', 'Alias /media-resources "%s"' % media_resources_dir, |
80 '-c', 'TypesConfig "%s"' % mime_types_path, | 81 '-c', 'TypesConfig "%s"' % mime_types_path, |
81 '-c', 'CustomLog "%s" common' % self._access_log_path, | 82 '-c', 'CustomLog "%s" common' % self._access_log_path, |
82 '-c', 'ErrorLog "%s"' % self._error_log_path, | 83 '-c', 'ErrorLog "%s"' % self._error_log_path, |
83 '-c', 'PidFile %s' % self._pid_file, | 84 '-c', 'PidFile %s' % self._pid_file, |
84 '-c', 'SSLCertificateFile "%s"' % cert_file, | 85 '-c', 'SSLCertificateFile "%s"' % cert_file, |
85 '-c', 'Alias /inspector-sources "%s"' % inspector_sources_dir, | 86 '-c', 'Alias /inspector-sources "%s"' % inspector_sources_dir, |
86 ] | 87 ] |
87 | 88 |
88 if self._is_win: | 89 if self._is_win: |
89 start_cmd += ['-c', "ThreadsPerChild %d" % (self._number_of_servers
* 8)] | 90 start_cmd += ['-c', "ThreadsPerChild %d" % (self._number_of_servers
* 8)] |
90 else: | 91 else: |
91 start_cmd += ['-c', "StartServers %d" % self._number_of_servers, | 92 start_cmd += ['-c', "StartServers %d" % self._number_of_servers, |
92 '-c', "MinSpareServers %d" % self._number_of_servers, | 93 '-c', "MinSpareServers %d" % self._number_of_servers, |
93 '-c', "MaxSpareServers %d" % self._number_of_servers, | 94 '-c', "MaxSpareServers %d" % self._number_of_servers, |
94 '-C', 'User "%s"' % os.environ.get('USERNAME', os.envi
ron.get('USER', '')), | 95 '-C', 'User "%s"' % os.environ.get('USERNAME', os.envi
ron.get('USER', '')), |
95 '-k', 'start'] | 96 '-k', 'start'] |
96 | 97 |
(...skipping 18 matching lines...) Expand all Loading... |
115 # We listen to both IPv4 and IPv6 loop-back addresses, but ignore | 116 # We listen to both IPv4 and IPv6 loop-back addresses, but ignore |
116 # requests to 8000 from random users on network. | 117 # requests to 8000 from random users on network. |
117 # See https://bugs.webkit.org/show_bug.cgi?id=37104 | 118 # See https://bugs.webkit.org/show_bug.cgi?id=37104 |
118 if enable_ipv6: | 119 if enable_ipv6: |
119 start_cmd += ['-C', "Listen [::1]:%d" % port] | 120 start_cmd += ['-C', "Listen [::1]:%d" % port] |
120 | 121 |
121 if additional_dirs: | 122 if additional_dirs: |
122 self._start_cmd = start_cmd | 123 self._start_cmd = start_cmd |
123 for alias, path in additional_dirs.iteritems(): | 124 for alias, path in additional_dirs.iteritems(): |
124 start_cmd += ['-c', 'Alias %s "%s"' % (alias, path), | 125 start_cmd += ['-c', 'Alias %s "%s"' % (alias, path), |
125 # Disable CGI handler for additional dirs. | 126 # Disable CGI handler for additional dirs. |
126 '-c', '<Location %s>' % alias, | 127 '-c', '<Location %s>' % alias, |
127 '-c', 'RemoveHandler .cgi .pl', | 128 '-c', 'RemoveHandler .cgi .pl', |
128 '-c', '</Location>'] | 129 '-c', '</Location>'] |
129 | 130 |
130 self._start_cmd = start_cmd | 131 self._start_cmd = start_cmd |
131 | 132 |
132 def _spawn_process(self): | 133 def _spawn_process(self): |
133 _log.debug('Starting %s server, cmd="%s"' % (self._name, str(self._start
_cmd))) | 134 _log.debug('Starting %s server, cmd="%s"' % (self._name, str(self._start
_cmd))) |
134 self._process = self._executive.popen(self._start_cmd) | 135 self._process = self._executive.popen(self._start_cmd) |
135 retval = self._process.returncode | 136 retval = self._process.returncode |
136 if retval: | 137 if retval: |
137 raise server_base.ServerError('Failed to start %s: %s' % (self._name
, retval)) | 138 raise server_base.ServerError('Failed to start %s: %s' % (self._name
, retval)) |
138 | 139 |
(...skipping 27 matching lines...) Expand all Loading... |
166 retval = proc.returncode | 167 retval = proc.returncode |
167 err = proc.stderr.read() | 168 err = proc.stderr.read() |
168 if retval or len(err): | 169 if retval or len(err): |
169 raise server_base.ServerError('Failed to stop %s: %s' % (self._name,
err)) | 170 raise server_base.ServerError('Failed to stop %s: %s' % (self._name,
err)) |
170 | 171 |
171 # For some reason apache isn't guaranteed to have actually stopped after | 172 # For some reason apache isn't guaranteed to have actually stopped after |
172 # the stop command returns, so we wait a little while longer for the | 173 # the stop command returns, so we wait a little while longer for the |
173 # pid file to be removed. | 174 # pid file to be removed. |
174 if not self._wait_for_action(lambda: not self._filesystem.exists(self._p
id_file)): | 175 if not self._wait_for_action(lambda: not self._filesystem.exists(self._p
id_file)): |
175 raise server_base.ServerError('Failed to stop %s: pid file still exi
sts' % self._name) | 176 raise server_base.ServerError('Failed to stop %s: pid file still exi
sts' % self._name) |
OLD | NEW |