fix access_log in run server and fix bool in env variables
This commit is contained in:
committed by
Sergey Fedoruk
parent
d76d5e2c5f
commit
391fcdc83d
16
sanic/app.py
16
sanic/app.py
@@ -977,7 +977,7 @@ class Sanic:
|
||||
backlog=100,
|
||||
stop_event=None,
|
||||
register_sys_signals=True,
|
||||
access_log=True,
|
||||
access_log=None,
|
||||
**kwargs
|
||||
):
|
||||
"""Run the HTTP Server and listen until keyboard interrupt or term
|
||||
@@ -1027,8 +1027,10 @@ class Sanic:
|
||||
"stop_event will be removed from future versions.",
|
||||
DeprecationWarning,
|
||||
)
|
||||
# compatibility old access_log params
|
||||
self.config.ACCESS_LOG = access_log
|
||||
# if access_log is passed explicitly change config.ACCESS_LOG
|
||||
if access_log is not None:
|
||||
self.config.ACCESS_LOG = access_log
|
||||
|
||||
server_settings = self._helper(
|
||||
host=host,
|
||||
port=port,
|
||||
@@ -1086,7 +1088,7 @@ class Sanic:
|
||||
protocol=None,
|
||||
backlog=100,
|
||||
stop_event=None,
|
||||
access_log=True,
|
||||
access_log=None,
|
||||
):
|
||||
"""
|
||||
Asynchronous version of :func:`run`.
|
||||
@@ -1114,8 +1116,10 @@ class Sanic:
|
||||
"stop_event will be removed from future versions.",
|
||||
DeprecationWarning,
|
||||
)
|
||||
# compatibility old access_log params
|
||||
self.config.ACCESS_LOG = access_log
|
||||
# if access_log is passed explicitly change config.ACCESS_LOG
|
||||
if access_log is not None:
|
||||
self.config.ACCESS_LOG = access_log
|
||||
|
||||
server_settings = self._helper(
|
||||
host=host,
|
||||
port=port,
|
||||
|
||||
@@ -12,23 +12,31 @@ BASE_LOGO = """
|
||||
|
||||
"""
|
||||
|
||||
DEFAULT_CONFIG = {
|
||||
"REQUEST_MAX_SIZE": 100000000, # 100 megabytes
|
||||
"REQUEST_BUFFER_QUEUE_SIZE": 100,
|
||||
"REQUEST_TIMEOUT": 60, # 60 seconds
|
||||
"RESPONSE_TIMEOUT": 60, # 60 seconds
|
||||
"KEEP_ALIVE": True,
|
||||
"KEEP_ALIVE_TIMEOUT": 5, # 5 seconds
|
||||
"WEBSOCKET_MAX_SIZE": 2 ** 20, # 1 megabytes
|
||||
"WEBSOCKET_MAX_QUEUE": 32,
|
||||
"WEBSOCKET_READ_LIMIT": 2 ** 16,
|
||||
"WEBSOCKET_WRITE_LIMIT": 2 ** 16,
|
||||
"GRACEFUL_SHUTDOWN_TIMEOUT": 15.0, # 15 sec
|
||||
"ACCESS_LOG": True,
|
||||
}
|
||||
|
||||
|
||||
class Config(dict):
|
||||
def __init__(self, defaults=None, load_env=True, keep_alive=True):
|
||||
def __init__(self, defaults=None, load_env=True, keep_alive=None):
|
||||
super().__init__(DEFAULT_CONFIG)
|
||||
super().__init__(defaults or {})
|
||||
|
||||
self.LOGO = BASE_LOGO
|
||||
self.REQUEST_MAX_SIZE = 100000000 # 100 megabytes
|
||||
self.REQUEST_BUFFER_QUEUE_SIZE = 100
|
||||
self.REQUEST_TIMEOUT = 60 # 60 seconds
|
||||
self.RESPONSE_TIMEOUT = 60 # 60 seconds
|
||||
self.KEEP_ALIVE = keep_alive
|
||||
self.KEEP_ALIVE_TIMEOUT = 5 # 5 seconds
|
||||
self.WEBSOCKET_MAX_SIZE = 2 ** 20 # 1 megabytes
|
||||
self.WEBSOCKET_MAX_QUEUE = 32
|
||||
self.WEBSOCKET_READ_LIMIT = 2 ** 16
|
||||
self.WEBSOCKET_WRITE_LIMIT = 2 ** 16
|
||||
self.GRACEFUL_SHUTDOWN_TIMEOUT = 15.0 # 15 sec
|
||||
self.ACCESS_LOG = True
|
||||
|
||||
if keep_alive is not None:
|
||||
self.KEEP_ALIVE = keep_alive
|
||||
|
||||
if load_env:
|
||||
prefix = SANIC_PREFIX if load_env is True else load_env
|
||||
@@ -116,4 +124,7 @@ class Config(dict):
|
||||
try:
|
||||
self[config_key] = float(v)
|
||||
except ValueError:
|
||||
self[config_key] = v
|
||||
if v in ['True', 'False']:
|
||||
self[config_key] = v == 'True'
|
||||
else:
|
||||
self[config_key] = v
|
||||
|
||||
@@ -58,9 +58,6 @@ class GunicornWorker(base.Worker):
|
||||
else self.http_protocol
|
||||
)
|
||||
|
||||
# set ACCESS_LOG on base of logging level
|
||||
self.app.callable.config.ACCESS_LOG = self.log.loglevel <= logging.INFO
|
||||
|
||||
self._server_settings = self.app.callable._helper(
|
||||
loop=self.loop,
|
||||
debug=is_debug,
|
||||
|
||||
Reference in New Issue
Block a user