core: update hook usage

This commit is contained in:
undefined committed 2022-09-23 20:10:36 +08:00
1 parent ab933bc9d5
commit 757b5e6bc1
27 files changed
+63 -64

No files matched your search

+4 -4
View File
@@ -46,7 +46,7 @@ const getLoader = (type: string, filename: string) => async function loader(pend
}
}
}
await bus.serial(`app/load/${type}`);
await bus.parallel(`app/load/${type}`);
};
export const handler = getLoader('handler', 'handler');
@@ -76,7 +76,7 @@ export async function locale(pending: string[], fail: string[]) {
}
}
}));
await bus.serial('app/load/locale');
await bus.parallel('app/load/locale');
}
export async function setting(pending: string[], fail: string[], modelSetting: typeof import('../model/setting')) {
@@ -117,7 +117,7 @@ export async function setting(pending: string[], fail: string[], modelSetting: t
}
}
}
await bus.serial('app/load/setting');
await bus.parallel('app/load/setting');
}
export async function template(pending: string[], fail: string[]) {
@@ -138,5 +138,5 @@ export async function template(pending: string[], fail: string[]) {
}
}
}
await bus.serial('app/load/template');
await bus.parallel('app/load/template');
}
+2 -3
View File
@@ -6,7 +6,6 @@ import cac from 'cac';
import fs from 'fs-extra';
import { Context } from '../context';
import { Logger } from '../logger';
import * as bus from '../service/bus';
import db from '../service/db';
import {
addon, handler, lib, locale, model,
@@ -61,7 +60,7 @@ export async function apply(ctx: Context) {
for (const i in global.Hydro.handler) await global.Hydro.handler[i]();
require('../script/index');
await script(pending, fail, ctx);
await bus.serial('app/started');
await ctx.parallel('app/started');
if (process.env.NODE_APP_INSTANCE === '0') {
const scripts = require('../upgrade').default;
let dbVer = (await modelSystem.get('db.ver')) ?? 0;
@@ -82,6 +81,6 @@ export async function apply(ctx: Context) {
}
logger.success('Server started');
process.send?.('ready');
await bus.serial('app/ready');
await ctx.parallel('app/ready');
return { fail };
}