*Add an async shutdown event so that plugins can take action before the swarm is destroyed

This commit is contained in:
Derrick Hammer 2023-01-05 19:39:03 -05:00
parent 6a41daff62
commit 831612bc77
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 2 additions and 1 deletions

View File

@ -2,7 +2,7 @@ import { start as startRpc } from "./modules/rpc.js";
import { start as startRelay } from "./modules/relay.js";
import { start as startApp } from "./modules/app";
import config from "./config.js";
import { loadPlugins } from "./modules/plugin.js";
import { getPluginAPI, loadPlugins } from "./modules/plugin.js";
import { start as startSwarm, get as getSwarm } from "./modules/swarm.js";
import * as bip39 from "@scure/bip39";
import { wordlist } from "@scure/bip39/wordlists/english";
@ -28,6 +28,7 @@ process.on("uncaughtException", function (err) {
});
async function shutdown() {
await getPluginAPI().emitAsync("core.shutdown");
await getSwarm().destroy();
process.exit();
}