add internal route to retire

This commit is contained in:
girish@cloudron.io
2016-01-25 20:21:04 -08:00
parent 33bc1cf7d9
commit 072962bbc3
2 changed files with 15 additions and 1 deletions
+14 -1
View File
@@ -4,7 +4,8 @@
exports = module.exports = {
backup: backup,
update: update
update: update,
retire: retire
};
var cloudron = require('../cloudron.js'),
@@ -39,3 +40,15 @@ function update(req, res, next) {
});
}
function retire(req, res, next) {
debug('triggering retire');
// note that cloudron.backup only waits for backup initiation and not for backup to complete
// backup progress can be checked up ny polling the progress api call
cloudron.retire(function (error) {
if (error && error.reason === CloudronError.BAD_STATE) return next(new HttpError(409, error.message));
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(202, {}));
});
}