完善任务调度

This commit is contained in:
小鹏 2022-07-27 17:43:24 +08:00
parent adf21bbe09
commit a0ab8e0d82
8 changed files with 26 additions and 18 deletions

View File

@ -1 +0,0 @@
time consuming12s

View File

@ -1 +0,0 @@
time consuming1s

View File

@ -1 +0,0 @@
time consuming0s

View File

@ -4,7 +4,7 @@
"description": "",
"private": true,
"dependencies": {
"@cool-midway/core": "^5.0.15",
"@cool-midway/core": "^5.1.4",
"@cool-midway/es": "^5.0.2",
"@cool-midway/file": "^5.0.5",
"@cool-midway/pay": "^5.0.0",

View File

@ -42,6 +42,11 @@ export default {
// },
// cool配置
cool: {
// redis: {
// host: '127.0.0.1',
// port: 6379,
// db: 0,
// },
// 是否自动导入数据库
file: {
// 上传模式 本地上传或云存储

View File

@ -7,10 +7,10 @@ import { MidwayConfig } from '@midwayjs/core';
export default {
orm: {
type: 'mysql',
host: '101.34.231.195',
host: '127.0.0.1',
port: 3306,
username: 'cool',
password: 'G4NCHwcc4aJipPMy',
username: 'root',
password: '123456',
database: 'cool',
// 自动建表 注意:线上部署的时候不要使用,有可能导致数据丢失
synchronize: true,
@ -20,15 +20,6 @@ export default {
charset: 'utf8mb4',
},
cool: {
rpc: {
name: 'main',
},
redis: {
host: '127.0.0.1',
port: 6379,
db: 1,
password: '',
},
// 是否自动导入数据库
initDB: true,
} as CoolConfig,

View File

@ -0,0 +1,17 @@
import { TaskInfoService } from './../service/info';
import { CoolEvent, Event } from '@cool-midway/core';
import { Inject } from '@midwayjs/decorator';
/**
*
*/
@CoolEvent()
export class AppEvent {
@Inject()
taskInfoService: TaskInfoService;
@Event('onServerReady')
async onServerReady() {
this.taskInfoService.initTask();
}
}

View File

@ -1,6 +1,5 @@
import {
App,
Init,
Inject,
Logger,
Provide,
@ -246,7 +245,6 @@ export class TaskInfoService extends BaseService {
/**
*
*/
@Init()
async initTask() {
setTimeout(async () => {
const runningTasks = await this.taskInfoEntity.find({ status: 1 });