| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 self._stop_running_server() | 140 self._stop_running_server() |
| 141 _log.debug("%s server at pid %d stopped" % (self._name, self._pid)) | 141 _log.debug("%s server at pid %d stopped" % (self._name, self._pid)) |
| 142 self._pid = None | 142 self._pid = None |
| 143 finally: | 143 finally: |
| 144 # Make sure we delete the pid file no matter what happens. | 144 # Make sure we delete the pid file no matter what happens. |
| 145 self._remove_pid_file() | 145 self._remove_pid_file() |
| 146 | 146 |
| 147 def _prepare_config(self): | 147 def _prepare_config(self): |
| 148 """This routine can be overridden by subclasses to do any sort | 148 """This routine can be overridden by subclasses to do any sort |
| 149 of initialization required prior to starting the server that may fail.""
" | 149 of initialization required prior to starting the server that may fail.""
" |
| 150 pass | |
| 151 | 150 |
| 152 def _remove_stale_logs(self): | 151 def _remove_stale_logs(self): |
| 153 """This routine can be overridden by subclasses to try and remove logs | 152 """This routine can be overridden by subclasses to try and remove logs |
| 154 left over from a prior run. This routine should log warnings if the | 153 left over from a prior run. This routine should log warnings if the |
| 155 files cannot be deleted, but should not fail unless failure to | 154 files cannot be deleted, but should not fail unless failure to |
| 156 delete the logs will actually cause start() to fail.""" | 155 delete the logs will actually cause start() to fail.""" |
| 157 # Sometimes logs are open in other processes but they should clear event
ually. | 156 # Sometimes logs are open in other processes but they should clear event
ually. |
| 158 for log_prefix in self._log_prefixes: | 157 for log_prefix in self._log_prefixes: |
| 159 try: | 158 try: |
| 160 self._remove_log_files(self._output_dir, log_prefix) | 159 self._remove_log_files(self._output_dir, log_prefix) |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 except IOError as e: | 273 except IOError as e: |
| 275 if e.errno in (errno.EALREADY, errno.EADDRINUSE): | 274 if e.errno in (errno.EALREADY, errno.EADDRINUSE): |
| 276 raise ServerError('Port %d is already in use.' % port) | 275 raise ServerError('Port %d is already in use.' % port) |
| 277 elif self._platform.is_win() and e.errno in (errno.WSAEACCES,):
# pylint: disable=E1101 | 276 elif self._platform.is_win() and e.errno in (errno.WSAEACCES,):
# pylint: disable=E1101 |
| 278 raise ServerError('Port %d is already in use.' % port) | 277 raise ServerError('Port %d is already in use.' % port) |
| 279 else: | 278 else: |
| 280 raise | 279 raise |
| 281 finally: | 280 finally: |
| 282 s.close() | 281 s.close() |
| 283 _log.debug('all ports are available') | 282 _log.debug('all ports are available') |
| OLD | NEW |