Add repair route
this is specifically for the case where some task failed and user wants to get it back.
This commit is contained in:
21
src/apps.js
21
src/apps.js
@@ -30,6 +30,7 @@ exports = module.exports = {
|
||||
setMailbox: setMailbox,
|
||||
setLocation: setLocation,
|
||||
setDataDir: setDataDir,
|
||||
repair: repair,
|
||||
|
||||
restore: restore,
|
||||
clone: clone,
|
||||
@@ -66,12 +67,13 @@ exports = module.exports = {
|
||||
// installation codes (keep in sync in UI)
|
||||
ISTATE_PENDING_INSTALL: 'pending_install', // installs and fresh reinstalls
|
||||
ISTATE_PENDING_CLONE: 'pending_clone', // clone
|
||||
ISTATE_PENDING_CONFIGURE: 'pending_configure', // config (location, port) changes and on infra update
|
||||
ISTATE_PENDING_CONFIGURE: 'pending_configure', // infra update
|
||||
ISTATE_PENDING_RECREATE_CONTAINER: 'pending_recreate_container', // env change or addon change
|
||||
ISTATE_PENDING_LOCATION_CHANGE: 'pending_location_change',
|
||||
ISTATE_PENDING_DATA_DIR_MIGRATION: 'pending_data_dir_migration',
|
||||
ISTATE_PENDING_RESIZE: 'pending_resize',
|
||||
ISTATE_PENDING_DEBUG: 'pending_debug',
|
||||
ISTATE_PENDING_REPAIR: 'pending_repair',
|
||||
ISTATE_PENDING_UNINSTALL: 'pending_uninstall', // uninstallation
|
||||
ISTATE_PENDING_RESTORE: 'pending_restore', // restore to previous backup or on upgrade
|
||||
ISTATE_PENDING_UPDATE: 'pending_update', // update from installed state preserving data
|
||||
@@ -1295,6 +1297,23 @@ function getLogs(appId, options, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function repair(appId, data, auditSource, callback) {
|
||||
assert.strictEqual(typeof appId, 'string');
|
||||
assert.strictEqual(typeof data, 'object');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
debug('Will repair app with id:%s', appId);
|
||||
|
||||
scheduleTask(appId, { /* task args */ }, { installationState: exports.ISTATE_PENDING_REPAIR }, function (error, result) {
|
||||
if (error) return callback(error);
|
||||
|
||||
eventlog.add(eventlog.ACTION_APP_REPAIR, auditSource, { taskId: result.taskId });
|
||||
|
||||
callback(null, { taskId: result.taskId });
|
||||
});
|
||||
}
|
||||
|
||||
function restore(appId, data, auditSource, callback) {
|
||||
assert.strictEqual(typeof appId, 'string');
|
||||
assert.strictEqual(typeof data, 'object');
|
||||
|
||||
Reference in New Issue
Block a user