From a0ab8e0d8216cd86e8ebba295b0da800888243cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=B9=8F?= Date: Wed, 27 Jul 2022 17:43:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BB=BB=E5=8A=A1=E8=B0=83?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lock/base.sql.lock | 1 - lock/dict.sql.lock | 1 - lock/task.sql.lock | 1 - package.json | 2 +- src/config/config.default.ts | 5 +++++ src/config/config.local.ts | 15 +++------------ src/modules/task/event/app.ts | 17 +++++++++++++++++ src/modules/task/service/info.ts | 2 -- 8 files changed, 26 insertions(+), 18 deletions(-) delete mode 100644 lock/base.sql.lock delete mode 100644 lock/dict.sql.lock delete mode 100644 lock/task.sql.lock create mode 100644 src/modules/task/event/app.ts diff --git a/lock/base.sql.lock b/lock/base.sql.lock deleted file mode 100644 index f7fb120..0000000 --- a/lock/base.sql.lock +++ /dev/null @@ -1 +0,0 @@ -time consuming:12s \ No newline at end of file diff --git a/lock/dict.sql.lock b/lock/dict.sql.lock deleted file mode 100644 index b2cef33..0000000 --- a/lock/dict.sql.lock +++ /dev/null @@ -1 +0,0 @@ -time consuming:1s \ No newline at end of file diff --git a/lock/task.sql.lock b/lock/task.sql.lock deleted file mode 100644 index a77002f..0000000 --- a/lock/task.sql.lock +++ /dev/null @@ -1 +0,0 @@ -time consuming:0s \ No newline at end of file diff --git a/package.json b/package.json index af02326..915a283 100755 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/config/config.default.ts b/src/config/config.default.ts index 1584696..202f1c0 100644 --- a/src/config/config.default.ts +++ b/src/config/config.default.ts @@ -42,6 +42,11 @@ export default { // }, // cool配置 cool: { + // redis: { + // host: '127.0.0.1', + // port: 6379, + // db: 0, + // }, // 是否自动导入数据库 file: { // 上传模式 本地上传或云存储 diff --git a/src/config/config.local.ts b/src/config/config.local.ts index c3a58de..67304ea 100644 --- a/src/config/config.local.ts +++ b/src/config/config.local.ts @@ -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, diff --git a/src/modules/task/event/app.ts b/src/modules/task/event/app.ts new file mode 100644 index 0000000..3245b58 --- /dev/null +++ b/src/modules/task/event/app.ts @@ -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(); + } +} diff --git a/src/modules/task/service/info.ts b/src/modules/task/service/info.ts index 56611ac..b8a2783 100644 --- a/src/modules/task/service/info.ts +++ b/src/modules/task/service/info.ts @@ -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 });