Skip to content

Commit e2214fb

Browse files
committed
feat: update Node.js version and refactor server entry points
1 parent 5597f5e commit e2214fb

File tree

5 files changed

+82
-4
lines changed

5 files changed

+82
-4
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v23.5.0
1+
v24.3.0

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ build: ## Build the project
2828

2929
.PHONY: start
3030
start: ## Start the project
31-
@pnpx tsx --import ./instrument.mjs --openssl-legacy-provider --env-file=.env src/server.ts
31+
@pnpx tsx --import ./instrument.mjs --openssl-legacy-provider --env-file=.env src/nps_server.ts
3232

3333
.PHONY: prod_node
3434
prod_node: ## Start the project in production mode

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"pre-commit": "lint-staged"
110110
}
111111
},
112-
"packageManager": "[email protected]+sha512.34e538c329b5553014ca8e8f4535997f96180a1d0f614339357449935350d924e22f8614682191264ec33d1462ac21561aff97f6bb18065351c162c7e8f6de67",
112+
"packageManager": "[email protected]+sha512.77f3fb0dbbd881835d7bd1217deabdf7ed77fc4ec4f363df64fc3cb986404abf6c437661041080f5c5d225103508e7c9ea30cb2742b7e942675d05a10af2d7b9",
113113
"pnpm": {
114114
"overrides": {
115115
"tinymce": "^7.9.1"

src/mcots_server.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// mcos is a game server, written from scratch, for an old game
2+
// Copyright (C) <2017> <Drazi Crendraven>
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published
6+
// by the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
import * as Sentry from "@sentry/node";
18+
import { Gateway } from "rusty-motors-gateway";
19+
import {
20+
getServerLogger,
21+
verifyLegacyCipherSupport,
22+
getServerConfiguration,
23+
} from "rusty-motors-shared";
24+
import { databaseService } from "rusty-motors-database";
25+
26+
function main() {
27+
const coreLogger = getServerLogger("mcots/core");
28+
29+
try {
30+
verifyLegacyCipherSupport();
31+
if (!databaseService.isDatabaseConnected) {
32+
coreLogger.fatal("Database connection failed. Exiting.");
33+
process.exit(1);
34+
}
35+
} catch (err) {
36+
coreLogger.fatal(`Error in core server: ${String(err)}`);
37+
process.exitCode = 1;
38+
return;
39+
}
40+
41+
try {
42+
const config = getServerConfiguration();
43+
const sanitizedConfig = {
44+
...config,
45+
certificateFile: "[REDACTED]",
46+
privateKeyFile: "[REDACTED]",
47+
publicKeyFile: "[REDACTED]",
48+
};
49+
coreLogger.debug(
50+
`Pre-flight checks passed. Starting server with config: ${JSON.stringify(sanitizedConfig)}`,
51+
);
52+
53+
const appLog = coreLogger.child({
54+
name: "app",
55+
level: config.logLevel,
56+
});
57+
58+
const listeningPortList = [
59+
43200, 43300, 43400,
60+
53303,
61+
];
62+
63+
const gatewayServer = new Gateway({
64+
config,
65+
log: appLog,
66+
listeningPortList,
67+
});
68+
69+
gatewayServer.start();
70+
} catch (err) {
71+
Sentry.captureException(err);
72+
coreLogger.fatal(`Error in core server: ${String(err)}`);
73+
process.exitCode = 1;
74+
return;
75+
}
76+
}
77+
78+
main();

src/server.ts renamed to src/nps_server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
import { databaseService } from "rusty-motors-database";
2525

2626
function main() {
27-
const coreLogger = getServerLogger("core");
27+
const coreLogger = getServerLogger("npx/core");
2828

2929
try {
3030
verifyLegacyCipherSupport();

0 commit comments

Comments
 (0)