Fix before_stop event
This commit is contained in:
parent
d1fb5bdc30
commit
1396ca903d
|
@ -64,6 +64,9 @@ class GunicornWorker(base.Worker):
|
||||||
trigger_events(self._server_settings.get('after_start', []),
|
trigger_events(self._server_settings.get('after_start', []),
|
||||||
self.loop)
|
self.loop)
|
||||||
self.loop.run_until_complete(self._check_alive())
|
self.loop.run_until_complete(self._check_alive())
|
||||||
|
trigger_events(self._server_settings.get('before_stop', []),
|
||||||
|
self.loop)
|
||||||
|
self.loop.run_until_complete(self.close())
|
||||||
finally:
|
finally:
|
||||||
trigger_events(self._server_settings.get('after_stop', []),
|
trigger_events(self._server_settings.get('after_stop', []),
|
||||||
self.loop)
|
self.loop)
|
||||||
|
@ -72,8 +75,6 @@ class GunicornWorker(base.Worker):
|
||||||
sys.exit(self.exit_code)
|
sys.exit(self.exit_code)
|
||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
trigger_events(self._server_settings.get('before_stop', []),
|
|
||||||
self.loop)
|
|
||||||
if self.servers:
|
if self.servers:
|
||||||
# stop accepting connections
|
# stop accepting connections
|
||||||
self.log.info("Stopping server: %s, connections: %s",
|
self.log.info("Stopping server: %s, connections: %s",
|
||||||
|
@ -115,8 +116,6 @@ class GunicornWorker(base.Worker):
|
||||||
except (Exception, BaseException, GeneratorExit, KeyboardInterrupt):
|
except (Exception, BaseException, GeneratorExit, KeyboardInterrupt):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
await self.close()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _create_ssl_context(cfg):
|
def _create_ssl_context(cfg):
|
||||||
""" Creates SSLContext instance for usage in asyncio.create_server.
|
""" Creates SSLContext instance for usage in asyncio.create_server.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user