mirror of
https://github.com/spacebarchat/server.git
synced 2026-08-21 22:59:52 +00:00
✨ add private and public endpoint
This commit is contained in:
+12
-4
@@ -24,16 +24,24 @@ const gateway = new GatewayServer({ server, port, production });
|
||||
async function main() {
|
||||
await initDatabase();
|
||||
await Config.init();
|
||||
// only set endpointPublic, if not already set
|
||||
await Config.set({
|
||||
cdn: {
|
||||
endpointClient: "${location.host}",
|
||||
endpoint: `http://localhost:${port}`,
|
||||
endpointPrivate: `http://localhost:${port}`,
|
||||
...(!Config.get().cdn.endpointPublic && {
|
||||
endpointPublic: `http://localhost:${port}`,
|
||||
}),
|
||||
},
|
||||
gateway: {
|
||||
endpointClient: '${location.protocol === "https:" ? "wss://" : "ws://"}${location.host}',
|
||||
endpoint: `ws://localhost:${port}`,
|
||||
endpointClient:
|
||||
'${location.protocol === "https:" ? "wss://" : "ws://"}${location.host}',
|
||||
endpointPrivate: `ws://localhost:${port}`,
|
||||
...(!Config.get().gateway.endpointPublic && {
|
||||
endpointPublic: `http://localhost:${port}`,
|
||||
}),
|
||||
},
|
||||
});
|
||||
} as any);
|
||||
|
||||
await Promise.all([api.start(), cdn.start(), gateway.start()]);
|
||||
console.log(`[Server] listening on port ${port}`);
|
||||
|
||||
+7
-3
@@ -9,16 +9,20 @@ export function initStats() {
|
||||
console.log(`[Process] running with pid: ${process.pid}`);
|
||||
|
||||
setInterval(async () => {
|
||||
const [cpuUsed, memory, network] = await Promise.all([osu.cpu.usage(), osu.mem.info(), osu.netstat.inOut()]);
|
||||
const [cpuUsed, memory, network] = await Promise.all([
|
||||
osu.cpu.usage(),
|
||||
osu.mem.info(),
|
||||
osu.netstat.inOut(),
|
||||
]);
|
||||
var networkUsage = "";
|
||||
if (typeof network === "object") {
|
||||
networkUsage = `| [Network]: in ${network.total.inputMb}mb | out ${network.total.outputMb}mb`;
|
||||
}
|
||||
|
||||
console.log(
|
||||
`[CPU] ${cpuUsed.toFixed(2)}% | [Memory] ${Math.round(
|
||||
`[CPU] ${cpuUsed.toPrecision(3)}% | [Memory] ${Math.round(
|
||||
process.memoryUsage().rss / 1024 / 1024
|
||||
)}mb/${memory.totalMemMb.toFixed(0)}mb ${networkUsage}`
|
||||
);
|
||||
}, 1000 * 30);
|
||||
}, 1000 * 5);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user