diff --git a/src/apptask.js b/src/apptask.js index c6683f639..f67953d82 100644 --- a/src/apptask.js +++ b/src/apptask.js @@ -64,7 +64,10 @@ var NOOP_CALLBACK = function (error) { if (error) debug(error); }; function initialize(callback) { assert.strictEqual(typeof callback, 'function'); - database.initialize(callback); + async.series([ + database.initialize, + settings.initCache + ], callback); } function debugApp(app) { diff --git a/src/provision.js b/src/provision.js index 3c2de40a4..d756cdd7e 100644 --- a/src/provision.js +++ b/src/provision.js @@ -279,10 +279,6 @@ function restore(backupConfig, backupId, version, auditSource, callback) { setProgress.bind(null, 'restore', 'Downloading backup'), backups.restore.bind(null, backupConfig, backupId, (progress) => setProgress('restore', progress.message, NOOP_CALLBACK)), setProgress.bind(null, 'restore', 'Applying auto-configuration'), - // currently, our suggested restore flow is after a dnsSetup. The dnSetup creates DKIM keys and updates the DNS - // for this reason, we have to re-setup DNS after a restore so it has DKIm from the backup - // Once we have a 100% IP based restore, we can skip this - mail.setDnsRecords.bind(null, settings.adminDomain()), eventlog.add.bind(null, eventlog.ACTION_RESTORE, auditSource, { backupId }), ], function (error) { gProvisionStatus.restore.active = false; diff --git a/src/scripts/backupupload.js b/src/scripts/backupupload.js index a8afaee63..7c6dd73c0 100755 --- a/src/scripts/backupupload.js +++ b/src/scripts/backupupload.js @@ -10,14 +10,19 @@ if (process.argv[2] === '--check') return console.log('OK'); require('supererror')({ splatchError: true }); var assert = require('assert'), + async = require('async'), backups = require('../backups.js'), database = require('../database.js'), - debug = require('debug')('box:backupupload'); + debug = require('debug')('box:backupupload'), + settings = require('../settings.js'); function initialize(callback) { assert.strictEqual(typeof callback, 'function'); - database.initialize(callback); + async.series([ + database.initialize, + settings.initCache + ], callback); } // Main process starts here diff --git a/src/taskworker.js b/src/taskworker.js index 4ae7a8172..0c00db447 100755 --- a/src/taskworker.js +++ b/src/taskworker.js @@ -3,11 +3,13 @@ require('supererror')({ splatchError: true }); var assert = require('assert'), + async = require('async'), backups = require('./backups.js'), database = require('./database.js'), debug = require('debug')('box:taskworker'), domains = require('./domains.js'), reverseProxy = require('./reverseproxy.js'), + settings = require('./settings.js'), tasks = require('./tasks.js'), updater = require('./updater.js'); @@ -33,10 +35,17 @@ process.on('SIGTERM', function () { assert.strictEqual(process.argv.length, 3, 'Pass the taskid as argument'); const taskId = process.argv[2]; +function initialize(callback) { + async.series([ + database.initialize, + settings.initCache + ], callback); +} + // Main process starts here debug(`Staring task ${taskId}`); -database.initialize(function (error) { +initialize(function (error) { if (error) return process.exit(50); tasks.get(taskId, function (error, task) {