core: storage: 热重载

This commit is contained in:
undefined committed 2021-01-21 22:48:18 +08:00
1 parent 99ac6e545d
commit 8c8dcb89eb
5 files changed
+24 -12

No files matched your search

+3 -1
View File
@@ -118,6 +118,7 @@ export function off<K extends keyof EventMap>(name: K, listener: EventMap[K]) {
export async function parallel<K extends keyof EventMap>(name: K, ...args: Parameters<EventMap[K]>): Promise<void> {
const tasks: Promise<any>[] = [];
if (argv.showBus) logger.debug('parallel: %s %o', name, args);
for (const callback of _hooks[name] || []) {
tasks.push(callback.apply(this, args));
}
@@ -166,7 +167,8 @@ async function messageHandler(worker: cluster.Worker, msg: any) {
for (const i in cluster.workers) {
cluster.workers[i].send(msg);
}
} else global.Hydro.service.bus.emit(msg.eventName, ...msg.payload);
}
emit(msg.eventName, ...msg.payload);
} else if (msg.event === 'stat') {
global.Hydro.stat.reqCount += msg.count;
} else await emit(msg.event, ...msg.payload);