delete container on network error
This commit is contained in:
+7
-2
@@ -55,6 +55,7 @@ var addons = require('./addons.js'),
|
|||||||
docker = require('./docker.js'),
|
docker = require('./docker.js'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
manifestFormat = require('cloudron-manifestformat'),
|
manifestFormat = require('cloudron-manifestformat'),
|
||||||
|
once = require('once'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
paths = require('./paths.js'),
|
paths = require('./paths.js'),
|
||||||
safe = require('safetydance'),
|
safe = require('safetydance'),
|
||||||
@@ -667,15 +668,19 @@ function exec(appId, options, callback) {
|
|||||||
container.resize({ h: options.rows, w: options.columns }, NOOP_CALLBACK);
|
container.resize({ h: options.rows, w: options.columns }, NOOP_CALLBACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var deleteContainer = once(docker.deleteContainer.bind(null, container.id, NOOP_CALLBACK));
|
||||||
|
|
||||||
container.wait(function (error) {
|
container.wait(function (error) {
|
||||||
if (error) debug('Error waiting on container', error);
|
if (error) debug('Error waiting on container', error);
|
||||||
|
|
||||||
debug('exec: container finished', container.id);
|
debug('exec: container finished', container.id);
|
||||||
|
|
||||||
docker.deleteContainer(container.id, NOOP_CALLBACK);
|
deleteContainer();
|
||||||
});
|
});
|
||||||
|
|
||||||
return callback(null, stream);
|
stream.close = deleteContainer;
|
||||||
|
|
||||||
|
callback(null, stream);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -368,6 +368,8 @@ function exec(req, res, next) {
|
|||||||
|
|
||||||
duplexStream.pipe(res.socket);
|
duplexStream.pipe(res.socket);
|
||||||
res.socket.pipe(duplexStream);
|
res.socket.pipe(duplexStream);
|
||||||
|
|
||||||
|
res.on('close', duplexStream.close);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user