relay/src/index.ts

44 lines
1.1 KiB
TypeScript
Raw Normal View History

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-07-24 00:24:19 +00:00
import log from "loglevel";
import config from "./config.js";
2022-09-21 12:59:22 +00:00
import { loadPlugins } from "./modules/plugin.js";
import { start as startDns } from "./modules/dns.js";
import { start as startSSl } from "./modules/ssl.js";
import { start as startSwarm } from "./modules/swarm.js";
import { generateSeedPhraseDeterministic } from "libskynet";
import * as crypto from "crypto";
2022-07-24 00:24:19 +00:00
log.setDefaultLevel(config.str("log-level"));
2022-06-27 17:53:00 +00:00
if (!config.str("seed")) {
config.saveConfigJson("account.json", {
seed: generateSeedPhraseDeterministic(
crypto.randomBytes(100).toString("hex")
)[0],
});
}
async function boot() {
await startSwarm();
await loadPlugins();
await startApp();
2022-09-09 10:18:14 +00:00
await startRpc();
await startDns();
await startSSl();
await startRelay();
}
2022-06-27 17:53:00 +00:00
boot();
2022-06-27 17:53:00 +00:00
process.on("uncaughtException", function (err) {
console.log(`Caught exception: ${err.message} ${err.stack}`);
2022-06-27 17:53:00 +00:00
});
2022-08-05 04:06:31 +00:00
process.on("SIGINT", function () {
process.exit();
});
process.on("SIGTERM", function () {
process.exit();
});