From 7ef3d55cbf4cf68b42e367ade1ecb86daf9cf0a4 Mon Sep 17 00:00:00 2001 From: "girish@cloudron.io" Date: Mon, 18 Jan 2016 11:16:06 -0800 Subject: [PATCH] add tty option to exec --- src/apps.js | 4 ++-- src/routes/apps.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/apps.js b/src/apps.js index 85aa056d9..63733a904 100644 --- a/src/apps.js +++ b/src/apps.js @@ -651,7 +651,7 @@ function exec(appId, options, callback) { AttachStdin: true, AttachStdout: true, AttachStderr: true, - Tty: true, + Tty: options.tty, Cmd: cmd }; @@ -659,7 +659,7 @@ function exec(appId, options, callback) { if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error)); var startOptions = { Detach: false, - Tty: true, + Tty: options.tty, stdin: true // this is a dockerode option that enabled openStdin in the modem }; exec.start(startOptions, function(error, stream) { diff --git a/src/routes/apps.js b/src/routes/apps.js index 855d06989..50e2c7b4f 100644 --- a/src/routes/apps.js +++ b/src/routes/apps.js @@ -357,7 +357,9 @@ function exec(req, res, next) { var rows = req.query.rows ? parseInt(req.query.rows, 10) : null; if (isNaN(rows)) return next(new HttpError(400, 'rows must be a number')); - apps.exec(req.params.id, { cmd: cmd, rows: rows, columns: columns }, function (error, duplexStream) { + var tty = req.query.tty === 'true' ? true : false; + + apps.exec(req.params.id, { cmd: cmd, rows: rows, columns: columns, tty: tty }, function (error, duplexStream) { if (error && error.reason === AppsError.NOT_FOUND) return next(new HttpError(404, 'No such app')); if (error && error.reason === AppsError.BAD_STATE) return next(new HttpError(409, error.message)); if (error) return next(new HttpError(500, error));