Fix double-printed logs after container restart

This commit is contained in:
Kostas Lekkas 2016-07-21 18:56:25 +03:00
parent 72ed2883fe
commit 761a0cbd82
2 changed files with 22 additions and 12 deletions

View File

@ -1,3 +1,4 @@
* Fix duplicate logs issue [Kostas]
* **[Breaking]** Do not bind mount /run/dbus to /run/dbus [Pablo]
* Default to not bind mounting kmod if container distro can't be found [Pablo]
* Use log-timestamp to add timestamps to logs [Pablo]

View File

@ -3,6 +3,7 @@ Docker = require 'dockerode'
PUBNUB = require 'pubnub'
Promise = require 'bluebird'
es = require 'event-stream'
Lock = require 'rwlock'
disableLogs = false
@ -52,8 +53,16 @@ exports.log = ->
publish(arguments...)
do ->
_lock = new Lock()
_writeLock = Promise.promisify(_lock.async.writeLock)
loggerLock = (containerId) ->
_writeLock(containerId)
.disposer (release) ->
release()
attached = {}
exports.attach = (app) ->
Promise.using loggerLock(app.containerId), ->
if !attached[app.containerId]
dockerPromise.then (docker) ->
docker.getContainer(app.containerId)