lib/mia-js.js
function () {
        const cronJobsToStart = _getNamesOfCronJobsToStart();
        if (!cronJobsToStart && _shouldStartCrons() && Shared.isDbConnectionAvailable() === true) {
            return CronJobManagerJob.startListening().then(function () {
                Logger.tag('Cron').info('Cron Job Manager is started. Starting all available cron jobs');
                return Q();
            }, function (err) {
                Logger.tag('Cron').error('Error starting Cron Job Manager ');
                return Q.reject(err);
            });
        } else if (cronJobsToStart && _shouldStartCrons()) {

            Logger.tag('Cron').info('Starting specific cron jobs "' + cronJobsToStart.join(', ') + '"');

            try {
                const cronJobs = Shared.cronModules(cronJobsToStart);
                let promises = [];
                for (let cron of cronJobs) {
                    // Set force run config
                    cron.forceRun = true;
                    promises.push(cron.worker(cron, cron));
                }
                return Q.all(promises)
                    .then(() => process.exit())
                    .catch(() => process.exit(1));
            } catch (err) {
                process.exit(1);
            }
        } else {
            Logger.tag('Cron').warn('Cron Manager is disabled for this environment.');
            return Q();
        }
    }
function () {
        const cronJobsToStart = _getNamesOfCronJobsToStart();
        if (!cronJobsToStart && _shouldStartCrons() && Shared.isDbConnectionAvailable() === true) {
            return CronJobManagerJob.startListening().then(function () {
                Logger.tag('Cron').info('Cron Job Manager is started. Starting all available cron jobs');
                return Q();
            }, function (err) {
                Logger.tag('Cron').error('Error starting Cron Job Manager ');
                return Q.reject(err);
            });
        } else if (cronJobsToStart && _shouldStartCrons()) {

            Logger.tag('Cron').info('Starting specific cron jobs "' + cronJobsToStart.join(', ') + '"');

            try {
                const cronJobs = Shared.cronModules(cronJobsToStart);
                let promises = [];
                for (let cron of cronJobs) {
                    // Set force run config
                    cron.forceRun = true;
                    promises.push(cron.worker(cron, cron));
                }
                return Q.all(promises)
                    .then(() => process.exit())
                    .catch(() => process.exit(1));
            } catch (err) {
                process.exit(1);
            }
        } else {
            Logger.tag('Cron').warn('Cron Manager is disabled for this environment.');
            return Q();
        }
    }
function ( ) { const cronJobsToStart = _getNamesOfCronJobsToStart ( ) ; if ( ! cronJobsToStart && _shouldStartCrons ( ) && Shared . isDbConnectionAvailable ( ) === true ) { return CronJobManagerJob . startListening ( ) . then ( function ( ) { Logger . tag ( 'Cron' ) . info ( 'Cron Job Manager is started. Starting all available cron jobs' ) ; return Q ( ) ; } , function ( err ) { Logger . tag ( 'Cron' ) . error ( 'Error starting Cron Job Manager ' ) ; return Q . reject ( err ) ; } ) ; } else if ( cronJobsToStart && _shouldStartCrons ( ) ) { Logger . tag ( 'Cron' ) . info ( 'Starting specific cron jobs "' + cronJobsToStart . join ( ', ' ) + '"' ) ; try { const cronJobs = Shared . cronModules ( cronJobsToStart ) ; let promises = [ ] ; for ( let cron of cronJobs ) { // Set force run config cron . forceRun = true ; promises . push ( cron . worker ( cron , cron ) ) ; } return Q . all ( promises ) . then ( ( ) => process . exit ( ) ) . catch ( ( ) => process . exit ( 1 ) ) ; } catch ( err ) { process . exit ( 1 ) ; } } else { Logger . tag ( 'Cron' ) . warn ( 'Cron Manager is disabled for this environment.' ) ; return Q ( ) ; } }
Start cron manager
@returns {*}
@private
Start cron manager