mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2024-11-01 14:10:29 +08:00
完善任务调度
This commit is contained in:
parent
adf21bbe09
commit
a0ab8e0d82
@ -1 +0,0 @@
|
|||||||
time consuming:12s
|
|
@ -1 +0,0 @@
|
|||||||
time consuming:1s
|
|
@ -1 +0,0 @@
|
|||||||
time consuming:0s
|
|
@ -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",
|
||||||
|
@ -42,6 +42,11 @@ export default {
|
|||||||
// },
|
// },
|
||||||
// cool配置
|
// cool配置
|
||||||
cool: {
|
cool: {
|
||||||
|
// redis: {
|
||||||
|
// host: '127.0.0.1',
|
||||||
|
// port: 6379,
|
||||||
|
// db: 0,
|
||||||
|
// },
|
||||||
// 是否自动导入数据库
|
// 是否自动导入数据库
|
||||||
file: {
|
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,
|
||||||
|
17
src/modules/task/event/app.ts
Normal file
17
src/modules/task/event/app.ts
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
@ -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 });
|
||||||
|
Loading…
Reference in New Issue
Block a user