start most cron jobs only after activation

Importing the db might take some time. If a cron runs in the middle,
it crashes.

TypeError: Cannot read property 'domain' of undefined
    at Object.fqdn (/home/yellowtent/box/src/domains.js:126:111)
    at /home/yellowtent/box/src/apps.js:460:36
    at /home/yellowtent/box/node_modules/async/dist/async.js:3110:16
    at replenish (/home/yellowtent/box/node_modules/async/dist/async.js:1011:17)
    at /home/yellowtent/box/node_modules/async/dist/async.js:1016:9
    at eachLimit$1 (/home/yellowtent/box/node_modules/async/dist/async.js:3196:24)
    at Object.<anonymous> (/home/yellowtent/box/node_modules/async/dist/async.js:1046:16)
    at /home/yellowtent/box/src/apps.js:458:19
    at /home/yellowtent/box/src/appdb.js:232:13
    at Query.args.(anonymous function) [as _callback] (/home/yellowtent/box/src/database.js
This commit is contained in:
Girish Ramakrishnan
2018-09-26 12:44:38 -07:00
parent 2967ad0ec8
commit a9c1af50f7
2 changed files with 18 additions and 9 deletions

View File

@@ -74,7 +74,7 @@ function initialize(callback) {
async.series([
settings.initialize,
reverseProxy.configureDefaultServer,
cron.initialize, // required for caas heartbeat before activation
cron.startPreActivationJobs,
onActivated
], callback);
}
@@ -83,7 +83,7 @@ function uninitialize(callback) {
assert.strictEqual(typeof callback, 'function');
async.series([
cron.uninitialize,
cron.stopJobs,
platform.stop,
settings.uninitialize
], callback);
@@ -99,7 +99,10 @@ function onActivated(callback) {
if (error) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, error));
if (!count) return callback(); // not activated
platform.start(callback);
async.series([
platform.start,
cron.startPostActivationJobs
], callback);
});
}