2022-09-21 12:59:22 +00:00
|
|
|
import { start as startRpc } from "./modules/rpc.js";
|
|
|
|
import { start as startRelay } from "./modules/relay.js";
|
|
|
|
import { start as startApp } from "./modules/app";
|
2022-08-03 06:02:40 +00:00
|
|
|
import config from "./config.js";
|
2022-09-21 12:59:22 +00:00
|
|
|
import { loadPlugins } from "./modules/plugin.js";
|
2023-01-06 00:36:06 +00:00
|
|
|
import { start as startSwarm, get as getSwarm } from "./modules/swarm.js";
|
2022-12-18 18:32:59 +00:00
|
|
|
import * as bip39 from "@scure/bip39";
|
|
|
|
import { wordlist } from "@scure/bip39/wordlists/english";
|
2022-07-24 00:24:19 +00:00
|
|
|
|
2022-09-21 20:40:10 +00:00
|
|
|
if (!config.str("seed")) {
|
2022-12-21 21:12:33 +00:00
|
|
|
config.save("account", {
|
2022-12-18 18:32:59 +00:00
|
|
|
seed: bip39.generateMnemonic(wordlist),
|
2022-09-21 20:40:10 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-07-24 03:16:34 +00:00
|
|
|
async function boot() {
|
2022-11-26 22:13:37 +00:00
|
|
|
await startSwarm();
|
2022-08-27 01:52:19 +00:00
|
|
|
await loadPlugins();
|
2022-09-21 12:55:35 +00:00
|
|
|
await startApp();
|
2022-09-09 10:18:14 +00:00
|
|
|
await startRpc();
|
2022-07-24 03:16:34 +00:00
|
|
|
await startRelay();
|
|
|
|
}
|
2022-06-27 17:53:00 +00:00
|
|
|
|
2022-07-25 06:50:27 +00:00
|
|
|
boot();
|
|
|
|
|
2022-06-27 17:53:00 +00:00
|
|
|
process.on("uncaughtException", function (err) {
|
2022-08-03 06:02:40 +00:00
|
|
|
console.log(`Caught exception: ${err.message} ${err.stack}`);
|
2022-06-27 17:53:00 +00:00
|
|
|
});
|
2023-01-06 00:36:06 +00:00
|
|
|
|
|
|
|
async function shutdown() {
|
|
|
|
await getSwarm().destroy();
|
2022-08-05 04:06:31 +00:00
|
|
|
process.exit();
|
2023-01-06 00:36:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
process.on("SIGINT", shutdown);
|
|
|
|
process.on("SIGTERM", shutdown);
|