mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-24 07:46:41 +00:00
Issues #23 and #236: Use docker logs to get all logs from the container, including those before supervisor start
We've been using docker attach, which only gives us the logs since we attach. This change allows getting the full logs from the beginning. We also use the timestamps that come with the logs from docker, as they will be more precise and are more relevant now that we're getting previous logs from history. Change-Type: patch Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
parent
b64ed9568c
commit
b6206f9012
@ -97,12 +97,17 @@ do ->
|
||||
if !attached[app.containerId]
|
||||
dockerPromise.then (docker) ->
|
||||
docker.getContainer(app.containerId)
|
||||
.attachAsync({ stream: true, stdout: true, stderr: true, tty: true })
|
||||
.logsAsync({ follow: true, stdout: true, stderr: true, timestamps: true })
|
||||
.then (stream) ->
|
||||
attached[app.containerId] = true
|
||||
stream.pipe(es.split())
|
||||
.on('data', publish)
|
||||
.on 'error', ->
|
||||
.on 'data', (logLine) ->
|
||||
space = logLine.indexOf(' ')
|
||||
if space > 0
|
||||
msg = { t: logLine.substr(0, space), m: logLine.substr(space + 1) }
|
||||
publish(msg)
|
||||
.on 'error', (err) ->
|
||||
console.error('Error on container logs', err, err.stack)
|
||||
attached[app.containerId] = false
|
||||
.on 'end', ->
|
||||
attached[app.containerId] = false
|
||||
|
Loading…
Reference in New Issue
Block a user