On dashboard or email location change, reconfigure immediately
This commit is contained in:
27
src/apps.js
27
src/apps.js
@@ -79,8 +79,8 @@ exports = module.exports = {
|
||||
canAutoupdateApp,
|
||||
autoupdateApps,
|
||||
|
||||
restoreInstalledApps,
|
||||
configureInstalledApps,
|
||||
restoreApps,
|
||||
configureApps,
|
||||
schedulePendingTasks,
|
||||
restartAppsUsingAddons,
|
||||
|
||||
@@ -2640,11 +2640,11 @@ async function getBackupDownloadStream(app, backupId) {
|
||||
return { stream: ps, filename };
|
||||
}
|
||||
|
||||
async function restoreInstalledApps(options, auditSource) {
|
||||
async function restoreApps(apps, options, auditSource) {
|
||||
assert(Array.isArray(apps));
|
||||
assert.strictEqual(typeof options, 'object');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
let apps = await list();
|
||||
apps = apps.filter(app => app.installationState !== exports.ISTATE_ERROR); // remove errored apps. let them be 'repaired' by hand
|
||||
apps = apps.filter(app => app.installationState !== exports.ISTATE_PENDING_RESTORE); // safeguard against tasks being created non-stop if we crash on startup
|
||||
|
||||
@@ -2668,34 +2668,37 @@ async function restoreInstalledApps(options, auditSource) {
|
||||
requireNullTaskId: false // ignore existing stale taskId
|
||||
};
|
||||
|
||||
debug(`restoreInstalledApps: marking ${app.fqdn} for restore using restore config ${JSON.stringify(restoreConfig)}`);
|
||||
debug(`restoreApps: marking ${app.fqdn} for restore using restore config ${JSON.stringify(restoreConfig)}`);
|
||||
|
||||
const [addTaskError, taskId] = await safe(addTask(app.id, installationState, task, auditSource));
|
||||
if (addTaskError) debug(`restoreInstalledApps: error marking ${app.fqdn} for restore: ${JSON.stringify(addTaskError)}`);
|
||||
else debug(`restoreInstalledApps: marked ${app.id} for restore with taskId ${taskId}`);
|
||||
if (addTaskError) debug(`restoreApps: error marking ${app.fqdn} for restore: ${JSON.stringify(addTaskError)}`);
|
||||
else debug(`restoreApps: marked ${app.id} for restore with taskId ${taskId}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function configureInstalledApps(apps, auditSource) {
|
||||
async function configureApps(apps, options, auditSource) {
|
||||
assert(Array.isArray(apps));
|
||||
assert.strictEqual(typeof options, 'object');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
apps = apps.filter(app => app.installationState !== exports.ISTATE_ERROR); // remove errored apps. let them be 'repaired' by hand
|
||||
apps = apps.filter(app => app.installationState !== exports.ISTATE_PENDING_CONFIGURE); // safeguard against tasks being created non-stop if we crash on startup
|
||||
|
||||
const scheduleNow = !!options.scheduleNow;
|
||||
|
||||
for (const app of apps) {
|
||||
debug(`configureInstalledApps: marking ${app.fqdn} for reconfigure`);
|
||||
debug(`configureApps: marking ${app.fqdn} for reconfigure (scheduleNow: ${scheduleNow})`);
|
||||
|
||||
const task = {
|
||||
args: {},
|
||||
values: {},
|
||||
scheduleNow: false, // task will be scheduled by autoRestartTasks when platform is ready
|
||||
scheduleNow,
|
||||
requireNullTaskId: false // ignore existing stale taskId
|
||||
};
|
||||
|
||||
const [addTaskError, taskId] = await safe(addTask(app.id, exports.ISTATE_PENDING_CONFIGURE, task, auditSource));
|
||||
if (addTaskError) debug(`configureInstalledApps: error marking ${app.fqdn} for configure: ${JSON.stringify(addTaskError)}`);
|
||||
else debug(`configureInstalledApps: marked ${app.id} for re-configure with taskId ${taskId}`);
|
||||
if (addTaskError) debug(`configureApps: error marking ${app.fqdn} for configure: ${JSON.stringify(addTaskError)}`);
|
||||
else debug(`configureApps: marked ${app.id} for re-configure with taskId ${taskId}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user