schedule.js 639 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const _ = require('lodash');
  3. const Subscription = require('egg').Subscription;
  4. class TaskPortal extends Subscription {
  5. // 通过 schedule 属性来设置定时任务的执行间隔等配置
  6. static get schedule() {
  7. // return {
  8. // interval: '5m',
  9. // type: 'all',
  10. // };
  11. }
  12. // // subscribe 是真正定时任务执行时被运行的函数
  13. async subscribe() {
  14. // const res = await this.ctx.curl('http://127.0.0.1:8081/api/servicetest/thousand', {
  15. // dataType: 'json',
  16. // });
  17. // console.log(res.data);
  18. await this.ctx.service.thousand.create();
  19. }
  20. }
  21. module.exports = TaskPortal;