Send connection message when streaming local mode logs

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-01-16 13:14:49 +00:00
parent 11fc93af0f
commit 06cdaddd71
No known key found for this signature in database
GPG Key ID: 49690ED87032539F

View File

@ -327,6 +327,13 @@ export function createV2Api(router: Router, applications: ApplicationManager) {
// Get the stream, and stream it into res
const listenStream = backend.attachListener();
// The http connection doesn't correctly intialise until some data is sent,
// which means any callers waiting on the data being returned will hang
// until the first logs comes through. To avoid this we send an initial
// message
res.write(
`${JSON.stringify({ message: 'Streaming logs', isSystem: true })}\n`,
);
listenStream.pipe(res);
});