diff --git a/src/apps.js b/src/apps.js index e6e827c4d..219250dc8 100644 --- a/src/apps.js +++ b/src/apps.js @@ -2022,11 +2022,17 @@ function restartAppsUsingAddons(changedAddons, callback) { args: {}, values: { runState: exports.RSTATE_RUNNING } }; - addTask(app.id, exports.ISTATE_PENDING_RESTART, task, function (error, result) { - if (error) debug(`restartAppsUsingAddons: error marking ${app.fqdn} for restart: ${JSON.stringify(error)}`); - else debug(`restartAppsUsingAddons: marked ${app.id} for restart with taskId ${result.taskId}`); - iteratorDone(); // ignore error + // stop apps before updating the databases because postgres will "lock" them preventing import + docker.stopContainers(app.id, function (error) { + if (error) debug(`restartAppsUsingAddons: error stopping ${app.fqdn}`, error); + + addTask(app.id, exports.ISTATE_PENDING_RESTART, task, function (error, result) { + if (error) debug(`restartAppsUsingAddons: error marking ${app.fqdn} for restart: ${JSON.stringify(error)}`); + else debug(`restartAppsUsingAddons: marked ${app.id} for restart with taskId ${result.taskId}`); + + iteratorDone(); // ignore error + }); }); }, callback); });