DO NOT RUN ANYTHING FROM THIS COMMIT
This commit is contained in:
parent
7a853e47a4
commit
a13bdea2eb
|
|
@ -3,7 +3,8 @@
|
||||||
"version": "0.1",
|
"version": "0.1",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ."
|
"start": "node .",
|
||||||
|
"dev": "nodemon ."
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ const logger = require("./lib/logger.js")
|
||||||
const express = require("express")
|
const express = require("express")
|
||||||
const app = express()
|
const app = express()
|
||||||
|
|
||||||
|
process.env.RCCSERVICE_PATH = "/tmp/Release"
|
||||||
|
|
||||||
app.use("/game/start", require("./routes/game/start.js"))
|
app.use("/game/start", require("./routes/game/start.js"))
|
||||||
app.use("/game/stop", require("./routes/game/stop.js"))
|
app.use("/game/stop", require("./routes/game/stop.js"))
|
||||||
app.use("/game/execute", require("./routes/game/execute.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, () => {
|
app.listen(process.env.PORT || 5173, () => {
|
||||||
logger.info(`Listening on http://127.0.0.1:${process.env.PORT || 5173}/`)
|
logger.info(`Listening on http://127.0.0.1:${process.env.PORT || 5173}/`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
process.on("uncaughtException", (err) => {
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
const Job = require("./Job.js")
|
||||||
|
|
||||||
|
class GameJob extends Job {
|
||||||
|
constructor() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = GameJob
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
const Job = require("./Job.js")
|
||||||
|
|
||||||
|
class RenderJob extends Job {
|
||||||
|
constructor() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = RenderJob
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
module.exports = (ms) => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, ms)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||||
|
|
||||||
local Player = game.Players:CreateLocalPlayer(0)
|
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)
|
Player:LoadCharacter(false)
|
||||||
|
|
||||||
game:GetService("RunService"):Run()
|
game:GetService("RunService"):Run()
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||||
|
|
||||||
local Player = game.Players:CreateLocalPlayer(0)
|
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)
|
Player:LoadCharacter(false)
|
||||||
|
|
||||||
game:GetService("RunService"):Run()
|
game:GetService("RunService"):Run()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,66 @@
|
||||||
|
const soap = require("soap")
|
||||||
|
const { readFileSync } = require("fs")
|
||||||
const express = require("express")
|
const express = require("express")
|
||||||
|
const RCCService = require("../lib/classes/RCCService")
|
||||||
|
const wait = require("../lib/wait")
|
||||||
const app = express.Router()
|
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
|
module.exports = app
|
||||||
|
|
|
||||||
|
|
@ -1,59 +1,6 @@
|
||||||
const { readFileSync } = require("fs")
|
|
||||||
const soap = require("soap")
|
|
||||||
const { randomUUID } = require("crypto")
|
|
||||||
|
|
||||||
const express = require("express")
|
const express = require("express")
|
||||||
const app = express.Router()
|
const app = express.Router()
|
||||||
|
|
||||||
app.get("/", async (request, response) => {
|
app.all("*", (request, response) => response.status(404).end())
|
||||||
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])
|
|
||||||
})
|
|
||||||
|
|
||||||
module.exports = app
|
module.exports = app
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue