-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.ts
41 lines (30 loc) · 968 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { TunnelServer } from "./src/server";
import { version } from "./package.json";
import { captureException, initExceptionHandler } from "./src/error-reporter";
process.title = "bored";
console.log(`~~ BoreD v${version} ~~`);
const tunnelAddress = process.env.TUNNEL_ADDRESS || "";
initExceptionHandler(tunnelAddress);
const serverPort = parseInt(process.env.PORT || "8080");
const agentToken = process.env.AGENT_TOKEN || "";
const idpPublicKey = process.env.IDP_PUBLIC_KEY;
if (!idpPublicKey) {
console.error("missing IDP_PUBLIC_KEY env, cannot continue");
process.exit(1);
}
process.on("uncaughtException", (err) => {
captureException(err);
setTimeout(() => {
process.exit(1);
}, 1000);
});
const server = new TunnelServer();
process.once("SIGTERM", () => {
server.stop();
process.exit(0);
});
process.once("SIGINT", () => {
server.stop();
process.exit(0);
});
server.start(serverPort, agentToken, idpPublicKey, tunnelAddress);