upd
This commit is contained in:
Vendored
+48
@@ -36,11 +36,15 @@ const child_process_1 = require("child_process");
|
||||
const tree_kill_1 = __importDefault(require("tree-kill"));
|
||||
const SessionServer_1 = __importDefault(require("./models/SessionServer"));
|
||||
const ActiveSession_1 = __importDefault(require("./models/ActiveSession"));
|
||||
const node_cron_1 = require("node-cron");
|
||||
const sendMessage_1 = __importDefault(require("./routes/sendMessage"));
|
||||
const ServerStatusLog_1 = __importDefault(require("./models/ServerStatusLog"));
|
||||
(0, db_1.default)();
|
||||
const app = (0, express_1.default)();
|
||||
const port = process.env.PORT;
|
||||
app.use((0, express_1.json)());
|
||||
app.use((0, cors_1.default)());
|
||||
app.use("/sendMessage", sendMessage_1.default);
|
||||
const serverLocation = process.env.SERVER_LOCATION;
|
||||
const serverName = process.env.SERVER_NAME;
|
||||
const serverType = process.env.SERVER_TYPE;
|
||||
@@ -170,6 +174,10 @@ async function endSession(activeSessionId) {
|
||||
}
|
||||
async function init() {
|
||||
try {
|
||||
await ServerStatusLog_1.default.create({
|
||||
hostname: serverHostname,
|
||||
action: "online",
|
||||
});
|
||||
await SessionServer_1.default.findOneAndUpdate({ hostname: serverHostname }, {
|
||||
location: serverLocation,
|
||||
name: serverName,
|
||||
@@ -210,3 +218,43 @@ app.listen(port, () => {
|
||||
console.log(`Server is listening on port ${port}`);
|
||||
init();
|
||||
});
|
||||
(0, node_cron_1.schedule)("*/3 * * * * *", async () => {
|
||||
// TODO - hostname
|
||||
try {
|
||||
const activeSessions = await ActiveSession_1.default.find({
|
||||
location: serverLocation,
|
||||
name: serverName,
|
||||
});
|
||||
for (const activeSession of activeSessions) {
|
||||
const { ueProcessId, buildName, uePort, id } = activeSession;
|
||||
const { stdout } = await execAsync(`wmic process where processId=${ueProcessId}`, { windowsHide: true });
|
||||
const ueProcessInfo = stdout.trim();
|
||||
if (ueProcessInfo)
|
||||
return;
|
||||
const filePath = `C:/pixel-streaming/builds/${buildName}/${buildName}.exe`;
|
||||
const newUeProcess = (0, child_process_1.execFile)(filePath, [
|
||||
"-PixelStreamingIP=127.0.0.1",
|
||||
`-PixelStreamingPort=${uePort}`,
|
||||
"-RenderOffScreen",
|
||||
"-ForceRes",
|
||||
"-ResX=1920",
|
||||
"-ResY=1080",
|
||||
"-Unattended",
|
||||
"-PixelStreamingWebRTCMinBitrate=5000000",
|
||||
"-PixelStreamingWebRTCMaxBitrate=20000000",
|
||||
"-PixelStreamingH264Profile=HIGH",
|
||||
"-PixelStreamingWebRTCDisableReceiveAudio=true",
|
||||
"-PixelStreamingEncoderRateControl=VBR",
|
||||
// "-PixelStreamingHudStats=true",
|
||||
// `-SessionID=${session.id}`,
|
||||
]);
|
||||
const newUeProcesscessId = newUeProcess.pid;
|
||||
await ActiveSession_1.default.findByIdAndUpdate(id, {
|
||||
ueProcessId: newUeProcesscessId,
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const express_1 = require("express");
|
||||
const router = (0, express_1.Router)();
|
||||
router.post("/", async (req, res) => {
|
||||
res.json({ ok: 1 });
|
||||
});
|
||||
const registerRouter = router;
|
||||
exports.default = registerRouter;
|
||||
Reference in New Issue
Block a user