remove exited supervisors

This commit is contained in:
Aleksis Brezas 2014-11-18 19:10:20 +00:00 committed by Pablo Carranza Vélez
parent 86c2e1280e
commit 433f0920c8

View File

@ -60,14 +60,14 @@ do ->
.map (app) ->
app.imageId + ':latest'
.then (apps) ->
# Make sure not to delete the supervisor image!
apps.push(config.localImage + ':latest')
apps.push(config.remoteImage + ':latest')
# Cleanup containers first, so that they don't block image removal.
supervisorImages = [ "#{config.localImage}:latest", "#{config.remoteImage}:latest" ]
docker.listContainersAsync(all: true)
.filter (containerInfo) ->
!_.contains(apps, containerInfo.Image) or !containerInfo.Status
isUserApp = _.contains(apps, containerInfo.Image)
isSupervisor = _.contains(supervisorImages, containerInfo.Image)
isRunning = !!containerInfo.Status
not (isUserApp or (isSupervisor and isRunning))
.map (containerInfo) ->
docker.getContainer(containerInfo.Id).removeAsync()
.then ->