完善任务调度

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": "", "description": "",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@cool-midway/core": "^5.0.15", "@cool-midway/core": "^5.1.4",
"@cool-midway/es": "^5.0.2", "@cool-midway/es": "^5.0.2",
"@cool-midway/file": "^5.0.5", "@cool-midway/file": "^5.0.5",
"@cool-midway/pay": "^5.0.0", "@cool-midway/pay": "^5.0.0",

View File

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

View File

@ -7,10 +7,10 @@ import { MidwayConfig } from '@midwayjs/core';
export default { export default {
orm: { orm: {
type: 'mysql', type: 'mysql',
host: '101.34.231.195', host: '127.0.0.1',
port: 3306, port: 3306,
username: 'cool', username: 'root',
password: 'G4NCHwcc4aJipPMy', password: '123456',
database: 'cool', database: 'cool',
// 自动建表 注意:线上部署的时候不要使用,有可能导致数据丢失 // 自动建表 注意:线上部署的时候不要使用,有可能导致数据丢失
synchronize: true, synchronize: true,
@ -20,15 +20,6 @@ export default {
charset: 'utf8mb4', charset: 'utf8mb4',
}, },
cool: { cool: {
rpc: {
name: 'main',
},
redis: {
host: '127.0.0.1',
port: 6379,
db: 1,
password: '',
},
// 是否自动导入数据库 // 是否自动导入数据库
initDB: true, initDB: true,
} as CoolConfig, } 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 { import {
App, App,
Init,
Inject, Inject,
Logger, Logger,
Provide, Provide,
@ -246,7 +245,6 @@ export class TaskInfoService extends BaseService {
/** /**
* *
*/ */
@Init()
async initTask() { async initTask() {
setTimeout(async () => { setTimeout(async () => {
const runningTasks = await this.taskInfoEntity.find({ status: 1 }); const runningTasks = await this.taskInfoEntity.find({ status: 1 });