From c1b1aba9853c2794f16c354fcf56b3e1d71df236 Mon Sep 17 00:00:00 2001 From: Pagan Gazzard Date: Tue, 19 Aug 2014 13:45:53 +0100 Subject: [PATCH] Make sure to stop any spawned tty sessions on container stop. --- src/application.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/application.coffee b/src/application.coffee index 9861d343..24058024 100644 --- a/src/application.coffee +++ b/src/application.coffee @@ -10,6 +10,7 @@ Promise = require 'bluebird' JSONStream = require 'JSONStream' PlatformAPI = require 'resin-platform-api/request' utils = require './utils' +tty = require './tty' PLATFORM_ENDPOINT = url.resolve(config.apiEndpoint, '/ewa/') resinAPI = new PlatformAPI(PLATFORM_ENDPOINT) @@ -44,7 +45,10 @@ exports.kill = kill = (app) -> updateDeviceInfo(status: 'Stopping') container = docker.getContainer(app.containerId) console.log('Stopping and deleting container:', container) - container.stopAsync() + tty.stop() + .catch(->) # Even if stopping the tty fails we want to finish stopping the container + .then -> + container.stopAsync() .then -> container.removeAsync() # Bluebird throws OperationalError for errors resulting in the normal execution of a promisified function.