Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(887)

Side by Side Diff: Tools/Scripts/webkitpy/layout_tests/servers/lighttpd.py

Issue 159723008: Refactor webkitpy.layout_tests.servers.server_base. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 def __init__(self, port_obj, output_dir, background=False, port=None, 43 def __init__(self, port_obj, output_dir, background=False, port=None,
44 root=None, run_background=None, additional_dirs=None, 44 root=None, run_background=None, additional_dirs=None,
45 layout_tests_dir=None, number_of_servers=None): 45 layout_tests_dir=None, number_of_servers=None):
46 """Args: 46 """Args:
47 output_dir: the absolute path to the layout test result directory 47 output_dir: the absolute path to the layout test result directory
48 """ 48 """
49 # Webkit tests 49 # Webkit tests
50 super(Lighttpd, self).__init__(port_obj, number_of_servers) 50 super(Lighttpd, self).__init__(port_obj, number_of_servers)
51 self._name = 'lighttpd' 51 self._name = 'lighttpd'
52 self._log_prefixes = ('access.log-', 'error.log-')
52 self._output_dir = output_dir 53 self._output_dir = output_dir
53 self._port = port 54 self._port = port
54 self._root = root 55 self._root = root
55 self._run_background = run_background 56 self._run_background = run_background
56 self._additional_dirs = additional_dirs 57 self._additional_dirs = additional_dirs
57 self._layout_tests_dir = layout_tests_dir 58 self._layout_tests_dir = layout_tests_dir
58 59
59 self._pid_file = self._filesystem.join(self._runtime_path, '%s.pid' % se lf._name) 60 self._pid_file = self._filesystem.join(self._runtime_path, '%s.pid' % se lf._name)
60 61
61 if self._port: 62 if self._port:
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 tmp_module_path = '/tmp/lighttpd/lib' 180 tmp_module_path = '/tmp/lighttpd/lib'
180 if not self._filesystem.exists(tmp_module_path): 181 if not self._filesystem.exists(tmp_module_path):
181 self._filesystem.maybe_make_directory(tmp_module_path) 182 self._filesystem.maybe_make_directory(tmp_module_path)
182 lib_file = 'liblightcomp.dylib' 183 lib_file = 'liblightcomp.dylib'
183 self._filesystem.copyfile(self._filesystem.join(module_path, lib_fil e), 184 self._filesystem.copyfile(self._filesystem.join(module_path, lib_fil e),
184 self._filesystem.join(tmp_module_path, lib _file)) 185 self._filesystem.join(tmp_module_path, lib _file))
185 186
186 self._start_cmd = start_cmd 187 self._start_cmd = start_cmd
187 self._env = self._port_obj.setup_environ_for_server('lighttpd') 188 self._env = self._port_obj.setup_environ_for_server('lighttpd')
188 self._mappings = mappings 189 self._mappings = mappings
189
190 def _remove_stale_logs(self):
191 # Sometimes logs are open in other processes but they should clear event ually.
192 for log_prefix in ('access.log-', 'error.log-'):
193 try:
194 self._remove_log_files(self._output_dir, log_prefix)
195 except OSError, e:
196 _log.warning('Failed to remove old %s %s files' % (self._name, l og_prefix))
197
198 def _spawn_process(self):
199 _log.debug('Starting %s server, cmd="%s"' % (self._name, self._start_cmd ))
200 process = self._executive.popen(self._start_cmd, env=self._env, shell=Fa lse, stderr=self._executive.PIPE)
201 pid = process.pid
202 self._filesystem.write_text_file(self._pid_file, str(pid))
203 return pid
204
205 def _stop_running_server(self):
206 # FIXME: It would be nice if we had a cleaner way of killing this proces s.
207 # Currently we throw away the process object created in _spawn_process,
208 # since there doesn't appear to be any way to kill the server any more
209 # cleanly using it than just killing the pid, and we need to support
210 # killing a pid directly anyway for run-webkit-httpd and run-webkit-webs ocketserver.
211 self._wait_for_action(self._check_and_kill)
212 if self._filesystem.exists(self._pid_file):
213 self._filesystem.remove(self._pid_file)
214
215 def _check_and_kill(self):
216 if self._executive.check_running_pid(self._pid):
217 host = self._port_obj.host
218 if host.platform.is_win() and not host.platform.is_cygwin():
219 # FIXME: https://bugs.webkit.org/show_bug.cgi?id=106838
220 # We need to kill all of the child processes as well as the
221 # parent, so we can't use executive.kill_process().
222 #
223 # If this is actually working, we should figure out a clean API.
224 self._executive.run_command(["taskkill.exe", "/f", "/t", "/pid", self._pid], error_handler=self._executive.ignore_error)
225 else:
226 self._executive.kill_process(self._pid)
227 return False
228 return True
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698