diff --git a/src/cloudron.js b/src/cloudron.js index 40b80f8f3..5dc4b4e2b 100644 --- a/src/cloudron.js +++ b/src/cloudron.js @@ -17,7 +17,6 @@ exports = module.exports = { retire: retire, migrate: migrate, - isConfiguredSync: isConfiguredSync, getConfigStateSync: getConfigStateSync, checkDiskSpace: checkDiskSpace, @@ -88,8 +87,7 @@ const BOX_AND_USER_TEMPLATE = { var gUpdatingDns = false, // flag for dns update reentrancy gBoxAndUserDetails = null, // cached cloudron details like region,size... - gIsConfigured = null, // cached configured state so that return value is synchronous. null means we are not initialized yet - gConfigState = { domain: false, dns: false, tls: false }; + gConfigState = { domain: false, dns: false, tls: false, configured: false }; function CloudronError(reason, errorOrMessage) { assert.strictEqual(typeof reason, 'string'); @@ -143,10 +141,6 @@ function uninitialize(callback) { callback(null); } -function isConfiguredSync() { - return gIsConfigured === true; -} - function getConfigStateSync() { return gConfigState; } @@ -170,8 +164,6 @@ function isConfigured(callback) { } function syncConfigState(callback) { - assert(!gIsConfigured); - callback = callback || NOOP_CALLBACK; isConfigured(function (error, configured) { @@ -180,13 +172,12 @@ function syncConfigState(callback) { debug('syncConfigState: configured = %s', configured); if (configured) { + gConfigState.configured = true; exports.events.emit(exports.EVENT_CONFIGURED); } else { settings.events.once(settings.DNS_CONFIG_KEY, function () { syncConfigState(); }); // check again later } - gIsConfigured = configured; - callback(); }); } diff --git a/src/mailer.js b/src/mailer.js index 4b5c3d67a..845501d1f 100644 --- a/src/mailer.js +++ b/src/mailer.js @@ -59,7 +59,7 @@ var gMailQueue = [ ], function initialize(callback) { assert.strictEqual(typeof callback, 'function'); - if (cloudron.isConfiguredSync()) { + if (cloudron.getConfigStateSync().configured) { checkDns(); } else { cloudron.events.on(cloudron.EVENT_CONFIGURED, checkDns); diff --git a/src/taskmanager.js b/src/taskmanager.js index 875253147..2074aae59 100644 --- a/src/taskmanager.js +++ b/src/taskmanager.js @@ -77,7 +77,7 @@ function waitForPendingTasks(callback) { } function platformReady() { - if (cloudron.isConfiguredSync()) { + if (cloudron.getConfigStateSync().configured) { debug('platformReady: configured, resuming tasks'); // cloudron-setup script relies on this log message resumeTasks(); } else {