mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-04-18 00:06:01 +00:00
logger: Only send logs produced after attaching
The previous approach had the bad side effect of resending tons of logs in the case of a supervisor restart. The approach can be improved by storing the last timestamp per container and re-attaching at the correct point. Change-type: minor Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
This commit is contained in:
parent
0d812c272c
commit
6766c23bd9
@ -187,7 +187,7 @@ module.exports = class Logger
|
||||
if stdoutOrStderr not in [ 'stdout', 'stderr' ]
|
||||
throw new Error("Invalid log selection #{stdoutOrStderr}")
|
||||
if !@attached[stdoutOrStderr][containerId]
|
||||
logsOpts = { follow: true, stdout: stdoutOrStderr == 'stdout', stderr: stdoutOrStderr == 'stderr', timestamps: true }
|
||||
logsOpts = { follow: true, stdout: stdoutOrStderr == 'stdout', stderr: stdoutOrStderr == 'stderr', timestamps: true, since: Math.floor(Date.now() / 1000) }
|
||||
docker.getContainer(containerId)
|
||||
.logs(logsOpts)
|
||||
.then (stream) =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user