little fix: fail outside of socket connection

This commit is contained in:
Marc Wäckerlin
2016-02-19 15:27:00 +00:00
parent ecba312335
commit 702a064814
2 changed files with 14 additions and 3 deletions

View File

@@ -17,6 +17,10 @@ module.exports = function(io) {
proc.exec(cmd, callback);
}
function fail(txt, data) {
console.log("** "+txt, data);
}
var oldcontainer = null;
function containerinspect(error, stdout, stderr) {
if (error || stderr)
@@ -96,7 +100,7 @@ module.exports = function(io) {
function modify(cmd, name) {
if (!name.match(/^[a-z0-9][-_:.+a-z0-9]*$/i))
return fail("illegal instance name");
return this.fail("illegal instance name");
exec("docker "+cmd+" "+name, updatecontainers);
}
@@ -104,7 +108,7 @@ module.exports = function(io) {
if (cmds.length>0)
exec(cmds.shift(), function(error, stdout, stderr) {
if (error || stderr)
return fail("create container failed", {
return this.fail("create container failed", {
error: error, stderr: stderr, stdout: stdout
});
createContainer(cmds);
@@ -175,7 +179,7 @@ module.exports = function(io) {
function new_bash(name) {
if (!name.match(/^[a-z0-9][-_:.+a-z0-9]*$/i))
return fail("illegal instance name");
return this.fail("illegal instance name");
if (bash_connections[name]) return;
bash_connections[name] =
pty.spawn("docker", ["exec", "-it", name, "bash", "-i"]);