-
Notifications
You must be signed in to change notification settings - Fork 14
/
server.ts
executable file
·82 lines (74 loc) · 2.74 KB
/
server.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// mcos is a game server, written from scratch, for an old game
// Copyright (C) <2017> <Drazi Crendraven>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import { exit } from "node:process";
import * as Sentry from "@sentry/node";
import { getGatewayServer } from "rusty-motors-gateway";
import { verifyLegacyCipherSupport } from "rusty-motors-gateway";
import { getServerConfiguration } from "rusty-motors-shared";
import { getServerLogger } from "rusty-motors-shared";
const coreLogger = getServerLogger({
name: "core",
});
try {
verifyLegacyCipherSupport();
} catch (err) {
coreLogger.fatal(`Error in core server: ${String(err)}`);
exit(1);
}
try {
if (typeof process.env["EXTERNAL_HOST"] === "undefined") {
console.error("Please set EXTERNAL_HOST");
process.exit(1);
}
if (typeof process.env["CERTIFICATE_FILE"] === "undefined") {
console.error("Please set CERTIFICATE_FILE");
process.exit(1);
}
if (typeof process.env["PRIVATE_KEY_FILE"] === "undefined") {
console.error("Please set PRIVATE_KEY_FILE");
process.exit(1);
}
if (typeof process.env["PUBLIC_KEY_FILE"] === "undefined") {
console.error("Please set PUBLIC_KEY_FILE");
process.exit(1);
}
const config = getServerConfiguration({
host: process.env["EXTERNAL_HOST"],
certificateFile: process.env["CERTIFICATE_FILE"],
privateKeyFile: process.env["PRIVATE_KEY_FILE"],
publicKeyFile: process.env["PUBLIC_KEY_FILE"],
logLevel: process.env["MCO_LOG_LEVEL"] || "info",
});
const appLog = getServerLogger({
level: config.logLevel,
name: "app",
});
const listeningPortList = [
6660, 7003, 8228, 8226, 8227, 9000, 9001, 9002, 9003, 9004, 9005, 9006,
9007, 9008, 9009, 9010, 9011, 9012, 9013, 9014, 43200, 43300, 43400,
53303,
];
const gatewayServer = getGatewayServer({
config,
log: appLog,
listeningPortList,
});
gatewayServer.start();
} catch (err) {
Sentry.captureException(err);
coreLogger.fatal(`Error in core server: ${String(err)}`);
process.exit(1);
}