Protocol configurable gunicorn worker
This commit is contained in:
parent
b755431b93
commit
47abf83960
|
@ -22,6 +22,9 @@ from sanic.websocket import WebSocketProtocol
|
||||||
|
|
||||||
class GunicornWorker(base.Worker):
|
class GunicornWorker(base.Worker):
|
||||||
|
|
||||||
|
http_protocol = HttpProtocol
|
||||||
|
websocket_protocol = WebSocketProtocol
|
||||||
|
|
||||||
def __init__(self, *args, **kw): # pragma: no cover
|
def __init__(self, *args, **kw): # pragma: no cover
|
||||||
super().__init__(*args, **kw)
|
super().__init__(*args, **kw)
|
||||||
cfg = self.cfg
|
cfg = self.cfg
|
||||||
|
@ -45,8 +48,9 @@ class GunicornWorker(base.Worker):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
is_debug = self.log.loglevel == logging.DEBUG
|
is_debug = self.log.loglevel == logging.DEBUG
|
||||||
protocol = (WebSocketProtocol if self.app.callable.websocket_enabled
|
protocol = (
|
||||||
else HttpProtocol)
|
self.websocket_protocol if self.app.callable.websocket_enabled
|
||||||
|
else self.http_protocol)
|
||||||
self._server_settings = self.app.callable._helper(
|
self._server_settings = self.app.callable._helper(
|
||||||
loop=self.loop,
|
loop=self.loop,
|
||||||
debug=is_debug,
|
debug=is_debug,
|
||||||
|
@ -136,8 +140,7 @@ class GunicornWorker(base.Worker):
|
||||||
if self.max_requests and req_count > self.max_requests:
|
if self.max_requests and req_count > self.max_requests:
|
||||||
self.alive = False
|
self.alive = False
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"Max requests exceeded, shutting down: %s", self
|
"Max requests exceeded, shutting down: %s", self)
|
||||||
)
|
|
||||||
elif pid == os.getpid() and self.ppid != os.getppid():
|
elif pid == os.getpid() and self.ppid != os.getppid():
|
||||||
self.alive = False
|
self.alive = False
|
||||||
self.log.info("Parent changed, shutting down: %s", self)
|
self.log.info("Parent changed, shutting down: %s", self)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user