chore: stabilize monorepo build and typescript setup
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.StatusReporter = void 0;
|
||||
const os_1 = __importDefault(require("os"));
|
||||
const config_1 = require("./config");
|
||||
const logger_1 = require("./logger");
|
||||
const logger = (0, logger_1.getLogger)("StatusReporter");
|
||||
class StatusReporter {
|
||||
constructor(channel, processManager, queryManager, wrapperId) {
|
||||
this.channel = channel;
|
||||
this.processManager = processManager;
|
||||
this.queryManager = queryManager;
|
||||
this.wrapperId = wrapperId;
|
||||
}
|
||||
start() {
|
||||
logger.debug("Status Reporter gestartet");
|
||||
setInterval(() => {
|
||||
this.sendStatus();
|
||||
}, config_1.WRAPPER_STATUS_INTERVAL);
|
||||
}
|
||||
sendStatus() {
|
||||
const processes = this.processManager.getStatus();
|
||||
const queries = this.queryManager.getStatus();
|
||||
const servers = processes.map(server => {
|
||||
const query = queries.find((q) => q.id === server.id);
|
||||
return {
|
||||
...server,
|
||||
players: query?.players ?? 0,
|
||||
maxPlayers: query?.maxPlayers ?? 0
|
||||
};
|
||||
});
|
||||
const status = {
|
||||
type: "wrapper.status",
|
||||
wrapperId: this.wrapperId,
|
||||
servers,
|
||||
ramFree: Math.round(os_1.default.freemem()
|
||||
/
|
||||
1024
|
||||
/
|
||||
1024)
|
||||
};
|
||||
this.channel.sendToQueue("wrapper.register", Buffer.from(JSON.stringify(status)));
|
||||
logger.debug("Status gesendet:", servers.length, "Server");
|
||||
}
|
||||
}
|
||||
exports.StatusReporter = StatusReporter;
|
||||
Reference in New Issue
Block a user