DO NOT RUN ANYTHING FROM THIS COMMIT

This commit is contained in:
I-Have-An-Issue 2023-01-19 19:17:01 -05:00
parent 7a853e47a4
commit a13bdea2eb
No known key found for this signature in database
GPG Key ID: E55435DEA0825091
11 changed files with 130 additions and 58 deletions

View File

@ -3,7 +3,8 @@
"version": "0.1",
"main": "src/index.js",
"scripts": {
"start": "node ."
"start": "node .",
"dev": "nodemon ."
},
"repository": {
"type": "git",

View File

@ -2,6 +2,8 @@ const logger = require("./lib/logger.js")
const express = require("express")
const app = express()
process.env.RCCSERVICE_PATH = "/tmp/Release"
app.use("/game/start", require("./routes/game/start.js"))
app.use("/game/stop", require("./routes/game/stop.js"))
app.use("/game/execute", require("./routes/game/execute.js"))
@ -15,3 +17,7 @@ app.use("*", require("./routes/index.js"))
app.listen(process.env.PORT || 5173, () => {
logger.info(`Listening on http://127.0.0.1:${process.env.PORT || 5173}/`)
})
process.on("uncaughtException", (err) => {
console.log(err)
})

View File

@ -0,0 +1,7 @@
const Job = require("./Job.js")
class GameJob extends Job {
constructor() {}
}
module.exports = GameJob

9
src/lib/classes/Job.js Normal file
View File

@ -0,0 +1,9 @@
const RCCService = require("./RCCService.js")
class Job extends RCCService {
constructor(id, expirationInSeconds = 10, category = 0, cores = 1) {
super()
}
}
module.exports = Job

View File

@ -0,0 +1,30 @@
const EventEmitter = require("events")
const child_process = require("child_process")
class RCCService extends EventEmitter {
constructor(path = process.env.RCCSERVICE_PATH) {
super()
this.path = path
}
start(port, options = { cwd: this.path }) {
return new Promise((resolve, reject) => {
try {
this.proc = child_process.spawn("wine", ["RCCService.exe", "-console", "-placeid:-1", `-port`, port], options)
this.proc.once("spawn", resolve(this.proc))
this.proc.once("exit", () => {
this.proc = null
})
} catch (_) {
reject(_)
}
})
}
stop(signal = "SIGTERM") {
if (!this.proc) throw new Error("Process is not running")
return this.proc.kill(signal)
}
}
module.exports = RCCService

View File

@ -0,0 +1,7 @@
const Job = require("./Job.js")
class RenderJob extends Job {
constructor() {}
}
module.exports = RenderJob

5
src/lib/wait.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = (ms) => {
return new Promise((resolve) => {
setTimeout(resolve, ms)
})
}

View File

@ -8,7 +8,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
game:GetService("ScriptContext").ScriptsDisabled = true
local Player = game.Players:CreateLocalPlayer(0)
Player.CharacterAppearance = ("%s/users/%d/character"):format(baseUrl, assetId)
Player.CharacterAppearance = ("%s/Users/%d/CharApp"):format(baseUrl, assetId)
Player:LoadCharacter(false)
game:GetService("RunService"):Run()

View File

@ -9,7 +9,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
game:GetService("ScriptContext").ScriptsDisabled = true
local Player = game.Players:CreateLocalPlayer(0)
Player.CharacterAppearance = ("%s/users/%d/character"):format(baseUrl, assetId)
Player.CharacterAppearance = ("%s/Users/%d/CharApp"):format(baseUrl, assetId)
Player:LoadCharacter(false)
game:GetService("RunService"):Run()

View File

@ -1,6 +1,66 @@
const soap = require("soap")
const { readFileSync } = require("fs")
const express = require("express")
const RCCService = require("../lib/classes/RCCService")
const wait = require("../lib/wait")
const app = express.Router()
app.all("*", (request, response) => response.status(200).end("Hi"))
app.all("*", async (request, response) => {
const rcc = new RCCService()
const proc = await rcc.start(64989)
if (proc.exitCode !== null) return response.json(false)
await wait(1000)
const jobId = "RenderTest"
const client = await soap.createClientAsync(__dirname + "/../lib/RCCService.wsdl", {}, "http://127.0.0.1:64989/")
const result = await client.OpenJobExAsync({
job: {
id: jobId,
expirationInSeconds: 10,
category: 0,
cores: 1,
},
script: {
name: jobId,
script: readFileSync(__dirname + "/../lua/user_headshot.lua", { encoding: "utf-8" }),
arguments: {
LuaValue: [
{
type: "LUA_TSTRING",
value: jobId,
},
{
type: "LUA_TSTRING",
value: "Avatar",
},
{
type: "LUA_TSTRING",
value: "PNG",
},
{
type: "LUA_TNUMBER",
value: "1920",
},
{
type: "LUA_TNUMBER",
value: "1920",
},
{
type: "LUA_TSTRING",
value: "https://economy.ittblox.gay",
},
{
type: "LUA_TNUMBER",
value: "1",
},
],
},
},
})
rcc.stop()
return response.end(Buffer.from(result[0].OpenJobExResult.LuaValue[0].value, "base64"))
})
module.exports = app

View File

@ -1,59 +1,6 @@
const { readFileSync } = require("fs")
const soap = require("soap")
const { randomUUID } = require("crypto")
const express = require("express")
const app = express.Router()
app.get("/", async (request, response) => {
let jobId = randomUUID()
const client = await soap.createClientAsync(__dirname + "/../../lib/RCCService.wsdl", {}, "http://127.0.0.1:64989/")
const result = await client.OpenJobExAsync({
job: {
id: jobId,
expirationInSeconds: 2,
category: 100,
cores: 1,
},
script: {
name: jobId,
script: readFileSync(__dirname + "/../../lua/user.lua", { encoding: "utf-8" }),
arguments: {
LuaValue: [
{
type: "LUA_TSTRING",
value: jobId,
},
{
type: "LUA_TSTRING",
value: "Avatar",
},
{
type: "LUA_TSTRING",
value: "PNG",
},
{
type: "LUA_TNUMBER",
value: "1920",
},
{
type: "LUA_TNUMBER",
value: "1920",
},
{
type: "LUA_TSTRING",
value: "https://economy.ittblox.gay",
},
{
type: "LUA_TNUMBER",
value: "-1",
},
],
},
},
})
response.json(result[0])
})
app.all("*", (request, response) => response.status(404).end())
module.exports = app