Interface. Scheduled Execution

12003

Interface Scheduled Execution

Newly added /app/schedule/testSchedule.js

'use strict';

module.exports = app => {
  return {
    schedule: {
      immediate: true,
      cron: "0 12,20 * * *", // Execute at 12:00 and 20:00 every day
      type: 'worker', // Only one worker executes
      disable: false,
    },
    async task(ctx) {
      const startTime = new Date().getTime();
      const { logger } = app;
      await ctx.service.test.test01();
      logger.info('[schedule/testSchedule.js]', { useTime: `${new Date().getTime() - startTime}/ms` });
    },
  };
};