Hi @all I’m working on docker logs streaming on sanic. I created streaming endpoint with stream logs
@app.route("/logs/stream")
async def test(request):
container_name = 'postgres'
client = from_env(assert_hostname='http+unix://var/run/docker.sock')
image = client.images.list(name='postgres')
containers = client.containers.list(filters={'ancestor': image[0].id})
id_cont = str(containers[0].id)
logs_container = client.containers.get(id_cont)
async def sample_streaming_fn(response):
logs = logs_container.logs(follow=True, tail=1, timestamps=True, stream=True)
for i in logs:
await response.write(i)
return stream(sample_streaming_fn, content_type='text/csv')
But i don’t understand how can i check if streaming work correct. How can I stream logs data from sanic?