*Ensure the swarm properly shuts down and un-announces itself
This commit is contained in:
parent
d569c5fd8b
commit
6a41daff62
14
src/index.ts
14
src/index.ts
|
@ -3,7 +3,7 @@ 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 { start as startSwarm } from "./modules/swarm.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";
|
||||
|
||||
|
@ -26,9 +26,11 @@ boot();
|
|||
process.on("uncaughtException", function (err) {
|
||||
console.log(`Caught exception: ${err.message} ${err.stack}`);
|
||||
});
|
||||
process.on("SIGINT", function () {
|
||||
|
||||
async function shutdown() {
|
||||
await getSwarm().destroy();
|
||||
process.exit();
|
||||
});
|
||||
process.on("SIGTERM", function () {
|
||||
process.exit();
|
||||
});
|
||||
}
|
||||
|
||||
process.on("SIGINT", shutdown);
|
||||
process.on("SIGTERM", shutdown);
|
||||
|
|
Loading…
Reference in New Issue