diff --git a/src/js/client.js b/src/js/client.js index 123707576..eeb58d765 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -21,6 +21,7 @@ var ISTATES = { PENDING_DEBUG: 'pending_debug', PENDING_START: 'pending_start', PENDING_STOP: 'pending_stop', + PENDING_RESTART: 'pending_restart', ERROR: 'error', INSTALLED: 'installed' }; @@ -555,25 +556,11 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; Client.prototype.restartApp = function (id, callback) { - var that = this; - - function waitUntilStopped(callback) { - that.getApp(id, function (error, result) { - if (error) return callback(error); - - if (result.runState === 'stopped') return callback(); - setTimeout(waitUntilStopped.bind(null, callback), 2000); - }); - } - - that.stopApp(id, function (error) { + post('/api/v1/apps/' + id + '/start', {}, null, function (error, data, status) { if (error) return callback(error); + if (status !== 202) return callback(new ClientError(status, data)); - waitUntilStopped(function (error) { - if (error) return callback(error); - - that.startApp(id, callback); - }); + callback(null, data); }); }; diff --git a/src/js/index.js b/src/js/index.js index ac4242566..b8c60d73f 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -327,6 +327,7 @@ app.filter('installationStateLabel', function () { case ISTATES.PENDING_BACKUP: return 'Backing up' + waiting; case ISTATES.PENDING_START: return 'Starting' + waiting; case ISTATES.PENDING_STOP: return 'Stopping' + waiting; + case ISTATES.PENDING_RESTART: return 'Restarting' + waiting; case ISTATES.ERROR: { if (app.error && app.error.message === 'ETRYAGAIN') return 'DNS Error'; return 'Error'; @@ -363,6 +364,7 @@ app.filter('taskName', function () { case ISTATES.PENDING_BACKUP: return 'backup'; case ISTATES.PENDING_START: return 'start app'; case ISTATES.PENDING_STOP: return 'stop app'; + case ISTATES.PENDING_RESTART: return 'restart app'; default: return installationState || ''; } }; diff --git a/src/js/terminal.js b/src/js/terminal.js index a4e6e4f47..b4faec9a4 100644 --- a/src/js/terminal.js +++ b/src/js/terminal.js @@ -127,27 +127,23 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client var appId = $scope.selected.value; - function waitUntilStopped(callback) { + function waitUntilRestarted(callback) { refreshApp(appId, function (error, result) { if (error) return callback(error); - if (result.installationState === ISTATES.INSTALLED && result.runState === RSTATES.STOPPED) return callback(); - setTimeout(waitUntilStopped.bind(null, callback), 2000); + if (result.installationState === ISTATES.INSTALLED) return callback(); + setTimeout(waitUntilRestarted.bind(null, callback), 2000); }); } - Client.stopApp(appId, function (error) { - if (error) console.error('Failed to stop app.', error); + Client.restartApp(appId, function (error) { + if (error) console.error('Failed to restart app.', error); - waitUntilStopped(function (error) { - if (error) console.error('Failed to get app status.', error); + waitUntilRestarted(function (error) { + if (error) console.error('Failed wait for restart.', error); - Client.startApp(appId, function (error) { - if (error) console.error('Failed to start app.', error); - - $scope.restartAppBusy = false; - $scope.appBusy = false; - }); + $scope.restartAppBusy = false; + $scope.appBusy = false; }); }); }; diff --git a/src/views/app.html b/src/views/app.html index f1b2da12f..34cfaf172 100644 --- a/src/views/app.html +++ b/src/views/app.html @@ -129,7 +129,7 @@
@@ -731,7 +731,7 @@This will open a console connection to the app. The terminal is sandboxed and only provides access to this app container's filesystem.
- Terminal + Terminal LogsIf the app is constantly restarting because of a broken plugin or misconfiguration, place the app in recovery mode. +
+ If the app is not responding, try restarting the app. If the app is constantly restarting because of a broken plugin or misconfiguration, + place the app in recovery mode in order to access the console. Use the following instructions to get the app running again.
+If a task (configuration, update, restore, backup) resulted in the app ending up in an error state, you can retry the operation.
+If a configuration, update, restore or backup action resulted in an error, you can retry the task.
An error occurred during the {{ app.error.installationState | taskName }} operation: {{ app.error.reason + ': ' + app.error.message }}
diff --git a/src/views/app.js b/src/views/app.js index 8b447a3fe..011921f94 100644 --- a/src/views/app.js +++ b/src/views/app.js @@ -801,7 +801,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location' }; $scope.repair = { - busy: false, + retryBusy: false, error: {}, location: null, @@ -816,7 +816,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location' // this prepares the repair dialog with whatever is required for repair action confirm: function () { $scope.repair.error = {}; - $scope.repair.busy = false; + $scope.repair.retryBusy = false; $scope.repair.location = null; $scope.repair.domain = null; $scope.repair.alternateDomains = []; @@ -856,7 +856,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location' submit: function () { $scope.repair.error = {}; - $scope.repair.busy = true; + $scope.repair.retryBusy = true; var errorState = ($scope.app.error && $scope.app.error.installationState) || ISTATES.PENDING_CONFIGURE; var data = {}; @@ -892,6 +892,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location' case ISTATES.PENDING_START: case ISTATES.PENDING_STOP: + case ISTATES.PENDING_RESTART: case ISTATES.PENDING_RESIZE: case ISTATES.PENDING_DEBUG: case ISTATES.PENDING_RECREATE_CONTAINER: @@ -906,7 +907,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location' repairFunc(function (error) { if (error) return Client.error(error); - $scope.repair.busy = false; + $scope.repair.retryBusy = false; $('#repairModal').modal('hide'); }); }, @@ -918,6 +919,23 @@ angular.module('Application').controller('AppController', ['$scope', '$location' }); }, + restartBusy: false, + restartApp: function () { + $scope.repair.restartBusy = true; + + Client.restartApp($scope.app.id, function (error) { + if (error) return console.error(error); + + refreshApp($scope.app.id, function () { + waitForAppTask(function (error) { + if (error) return Client.error(error); + + $scope.repair.restartBusy = false; + }); + }); + }); + }, + pauseBusy: false, pauseAppBegin: function () {