summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2019-06-20 02:19:27 +0300
committerDevaev Maxim <[email protected]>2019-06-20 02:19:27 +0300
commita7649f9cf7818690fc45d8c85178c91fe61c5f32 (patch)
treeb47c393c97a5d864369dc65bed0b39d0dbea6dcb
parent528bdf6a6d329f1c22b712787b833ed17e1ac17e (diff)
/log handle raises an error if journald is not available
-rw-r--r--kvmd/apps/kvmd/server.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/kvmd/apps/kvmd/server.py b/kvmd/apps/kvmd/server.py
index 5520b13e..b8d3aa3a 100644
--- a/kvmd/apps/kvmd/server.py
+++ b/kvmd/apps/kvmd/server.py
@@ -335,9 +335,11 @@ class Server: # pylint: disable=too-many-instance-attributes
async def __log_handler(self, request: aiohttp.web.Request) -> aiohttp.web.StreamResponse:
seek = valid_log_seek(request.query.get("seek", "0"))
follow = valid_bool(request.query.get("follow", "false"))
- response = aiohttp.web.StreamResponse(status=200, reason="OK", headers={"Content-Type": "text/plain"})
- await response.prepare(request)
+ response: Optional[aiohttp.web.StreamResponse] = None
async for record in self.__log_reader.poll_log(seek, follow):
+ if response is None:
+ response = aiohttp.web.StreamResponse(status=200, reason="OK", headers={"Content-Type": "text/plain"})
+ await response.prepare(request)
await response.write(("[%s %s] --- %s" % (
record["dt"].strftime("%Y-%m-%d %H:%M:%S"),
record["service"],