| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 self._pid = actual_pid | 123 self._pid = actual_pid |
| 124 | 124 |
| 125 if not self._pid: | 125 if not self._pid: |
| 126 return | 126 return |
| 127 | 127 |
| 128 if not actual_pid: | 128 if not actual_pid: |
| 129 _log.warning('Failed to stop %s: pid file is missing' % self._na
me) | 129 _log.warning('Failed to stop %s: pid file is missing' % self._na
me) |
| 130 return | 130 return |
| 131 if self._pid != actual_pid: | 131 if self._pid != actual_pid: |
| 132 _log.warning('Failed to stop %s: pid file contains %d, not %d' % | 132 _log.warning('Failed to stop %s: pid file contains %d, not %d' % |
| 133 (self._name, actual_pid, self._pid)) | 133 (self._name, actual_pid, self._pid)) |
| 134 # Try to kill the existing pid, anyway, in case it got orphaned. | 134 # Try to kill the existing pid, anyway, in case it got orphaned. |
| 135 self._executive.kill_process(self._pid) | 135 self._executive.kill_process(self._pid) |
| 136 self._pid = None | 136 self._pid = None |
| 137 return | 137 return |
| 138 | 138 |
| 139 _log.debug("Attempting to shut down %s server at pid %d" % (self._na
me, self._pid)) | 139 _log.debug("Attempting to shut down %s server at pid %d" % (self._na
me, self._pid)) |
| 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: |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 except IOError, e: | 274 except IOError, e: |
| 275 if e.errno in (errno.EALREADY, errno.EADDRINUSE): | 275 if e.errno in (errno.EALREADY, errno.EADDRINUSE): |
| 276 raise ServerError('Port %d is already in use.' % port) | 276 raise ServerError('Port %d is already in use.' % port) |
| 277 elif self._platform.is_win() and e.errno in (errno.WSAEACCES,):
# pylint: disable=E1101 | 277 elif self._platform.is_win() and e.errno in (errno.WSAEACCES,):
# pylint: disable=E1101 |
| 278 raise ServerError('Port %d is already in use.' % port) | 278 raise ServerError('Port %d is already in use.' % port) |
| 279 else: | 279 else: |
| 280 raise | 280 raise |
| 281 finally: | 281 finally: |
| 282 s.close() | 282 s.close() |
| 283 _log.debug('all ports are available') | 283 _log.debug('all ports are available') |
| OLD | NEW |