better access log

This commit is contained in:
Devaev Maxim 2018-12-16 02:28:13 +03:00
parent e5dfc9e306
commit d7fb06d22e
5 changed files with 16 additions and 4 deletions

View File

@ -6,6 +6,7 @@ kvmd:
host: 127.0.0.1
port: 8081
heartbeat: 3.0
access_log_format: "[%{X-Real-IP}i] '%r' => %s; size=%b --- referer='%{Referer}i'; user_agent='%{User-Agent}i'"
auth:
htpasswd: /etc/kvmd/htpasswd

View File

@ -6,6 +6,7 @@ kvmd:
host: 127.0.0.1
port: 8081
heartbeat: 3.0
access_log_format: "[%{X-Real-IP}i] '%r' => %s; size=%b --- referer='%{Referer}i'; user_agent='%{User-Agent}i'"
auth:
htpasswd: /etc/kvmd/htpasswd

View File

@ -94,6 +94,7 @@ def main() -> None:
msd=msd,
streamer=streamer,
access_log_format=str(config["server"]["access_log_format"]),
heartbeat=float(config["server"]["heartbeat"]),
streamer_shutdown_delay=float(config["streamer"]["shutdown_delay"]),
msd_chunk_size=int(config["msd"]["chunk_size"]),

View File

@ -198,6 +198,7 @@ class Server: # pylint: disable=too-many-instance-attributes
msd: MassStorageDevice,
streamer: Streamer,
access_log_format: str,
heartbeat: float,
streamer_shutdown_delay: float,
msd_chunk_size: int,
@ -214,6 +215,7 @@ class Server: # pylint: disable=too-many-instance-attributes
self.__msd = msd
self.__streamer = streamer
self.__access_log_format = access_log_format
self.__heartbeat = heartbeat
self.__streamer_shutdown_delay = streamer_shutdown_delay
self.__msd_chunk_size = msd_chunk_size
@ -251,17 +253,23 @@ class Server: # pylint: disable=too-many-instance-attributes
assert port or unix_path
if unix_path:
kwargs: Dict = {}
socket_kwargs: Dict = {}
if unix_rm and os.path.exists(unix_path):
os.remove(unix_path)
server_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
server_socket.bind(unix_path)
if unix_mode:
os.chmod(unix_path, unix_mode)
kwargs = {"sock": server_socket}
socket_kwargs = {"sock": server_socket}
else:
kwargs = {"host": host, "port": port}
aiohttp.web.run_app(app, print=self.__run_app_print, **kwargs)
socket_kwargs = {"host": host, "port": port}
aiohttp.web.run_app(
app=app,
access_log_format=self.__access_log_format,
print=self.__run_app_print,
**socket_kwargs,
)
async def __make_info(self) -> Dict:
return {

View File

@ -3,6 +3,7 @@ kvmd:
host: 0.0.0.0
port: 8081
heartbeat: 3.0
access_log_format: "[%{X-Real-IP}i] '%r' => %s; size=%b --- referer='%{Referer}i'; user_agent='%{User-Agent}i'"
auth:
htpasswd: /etc/kvmd/htpasswd