Keep building classes
This commit is contained in:
parent
a13bdea2eb
commit
63924d654d
|
|
@ -1,3 +1 @@
|
|||
# bingle-arbiter
|
||||
|
||||
Run `npm run build`, compiled binaries are in `build/`
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@
|
|||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
"express": "^4.18.2",
|
||||
"soap": "^1.0.0"
|
||||
"soap": "^1.0.0",
|
||||
"wait-port": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@xmldom/xmldom": {
|
||||
|
|
@ -190,6 +191,14 @@
|
|||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/commander": {
|
||||
"version": "9.5.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz",
|
||||
"integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==",
|
||||
"engines": {
|
||||
"node": "^12.20.0 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/content-disposition": {
|
||||
"version": "0.5.4",
|
||||
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
|
||||
|
|
@ -939,6 +948,22 @@
|
|||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/wait-port": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/wait-port/-/wait-port-1.0.4.tgz",
|
||||
"integrity": "sha512-w8Ftna3h6XSFWWc2JC5gZEgp64nz8bnaTp5cvzbJSZ53j+omktWTDdwXxEF0jM8YveviLgFWvNGrSvRHnkyHyw==",
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
"commander": "^9.3.0",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"bin": {
|
||||
"wait-port": "bin/wait-port.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/whatwg-mimetype": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz",
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
"express": "^4.18.2",
|
||||
"soap": "^1.0.0"
|
||||
"soap": "^1.0.0",
|
||||
"wait-port": "^1.0.4"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ app.use("/render/game", require("./routes/render/game.js"))
|
|||
|
||||
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}/`)
|
||||
app.listen(process.env.PORT || 64989, () => {
|
||||
logger.info(`Listening on http://127.0.0.1:${process.env.PORT || 64989}/`)
|
||||
})
|
||||
|
||||
process.on("uncaughtException", (err) => {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,43 @@
|
|||
const RCCService = require("./RCCService.js")
|
||||
const soap = require("soap")
|
||||
|
||||
class Job extends RCCService {
|
||||
constructor(id, expirationInSeconds = 10, category = 0, cores = 1) {
|
||||
super()
|
||||
constructor(id, port, expirationInSeconds = 10, category = 0, cores = 1) {
|
||||
super(port)
|
||||
this.id = id
|
||||
this.expirationInSeconds = expirationInSeconds
|
||||
this.category = category
|
||||
this.cores = cores
|
||||
}
|
||||
|
||||
async CreateClient() {
|
||||
this.client = await soap.createClientAsync(__dirname + "/../RCCService.wsdl", {}, `http://127.0.0.1:${this.port}/`)
|
||||
return this.client
|
||||
}
|
||||
|
||||
async Open(script) {
|
||||
if (!this.client) throw new Error("There is no client")
|
||||
return await this.client.OpenJobExAsync({
|
||||
job: {
|
||||
id: this.id,
|
||||
expirationInSeconds: this.expirationInSeconds,
|
||||
category: this.category,
|
||||
cores: this.cores,
|
||||
},
|
||||
script,
|
||||
})
|
||||
}
|
||||
|
||||
async Close() {
|
||||
if (!this.client) return true
|
||||
return await this.client.CloseAllJobsAsync({})
|
||||
}
|
||||
|
||||
async RenewLease(expirationInSeconds) {
|
||||
return await this.client.RenewLeaseAsync({
|
||||
jobID: this.id,
|
||||
expirationInSeconds,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,16 +2,17 @@ const EventEmitter = require("events")
|
|||
const child_process = require("child_process")
|
||||
|
||||
class RCCService extends EventEmitter {
|
||||
constructor(path = process.env.RCCSERVICE_PATH) {
|
||||
constructor(port, path = process.env.RCCSERVICE_PATH) {
|
||||
super()
|
||||
this.path = path
|
||||
this.port = port
|
||||
}
|
||||
|
||||
start(port, options = { cwd: this.path }) {
|
||||
Start(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 = child_process.spawn("wine", ["RCCService.exe", "-Console", "-PlaceId:-1", `-Port`, this.port], options)
|
||||
this.proc.once("spawn", () => resolve(this))
|
||||
this.proc.once("exit", () => {
|
||||
this.proc = null
|
||||
})
|
||||
|
|
@ -21,7 +22,7 @@ class RCCService extends EventEmitter {
|
|||
})
|
||||
}
|
||||
|
||||
stop(signal = "SIGTERM") {
|
||||
Stop(signal = "SIGTERM") {
|
||||
if (!this.proc) throw new Error("Process is not running")
|
||||
return this.proc.kill(signal)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,65 +1,39 @@
|
|||
const soap = require("soap")
|
||||
const { readFileSync } = require("fs")
|
||||
const waitPort = require("wait-port")
|
||||
const { readFileSync, read } = require("fs")
|
||||
const express = require("express")
|
||||
const RCCService = require("../lib/classes/RCCService")
|
||||
const wait = require("../lib/wait")
|
||||
const Job = require("../lib/classes/Job.js")
|
||||
const app = express.Router()
|
||||
|
||||
let tempPort = 64990
|
||||
|
||||
app.all("*", async (request, response) => {
|
||||
const rcc = new RCCService()
|
||||
const proc = await rcc.start(64989)
|
||||
if (proc.exitCode !== null) return response.json(false)
|
||||
const job = new Job("KILL JACKD", tempPort)
|
||||
await job.Start()
|
||||
|
||||
await wait(1000)
|
||||
const { open } = await waitPort({ host: "127.0.0.1", port: tempPort, timeout: 5000, output: "silent" })
|
||||
if (!open) {
|
||||
job.Close()
|
||||
return response.json(false)
|
||||
}
|
||||
|
||||
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",
|
||||
},
|
||||
],
|
||||
},
|
||||
await job.CreateClient()
|
||||
const result = await job.Open({
|
||||
name: job.id,
|
||||
script: readFileSync(__dirname + "/../lua/user_headshot.lua", { encoding: "utf-8" }),
|
||||
arguments: {
|
||||
LuaValue: [
|
||||
{ type: "LUA_TSTRING", value: job.id },
|
||||
{ type: "LUA_TSTRING", value: "RenderUserHeadshot" },
|
||||
{ type: "LUA_TSTRING", value: "PNG" },
|
||||
{ type: "LUA_TNUMBER", value: "1920" },
|
||||
{ type: "LUA_TNUMBER", value: "1920" },
|
||||
{ type: "LUA_TSTRING", value: "https://sitetest.unexp.xyz" },
|
||||
{ type: "LUA_TNUMBER", value: "1" },
|
||||
],
|
||||
},
|
||||
})
|
||||
await job.Stop()
|
||||
|
||||
rcc.stop()
|
||||
return response.end(Buffer.from(result[0].OpenJobExResult.LuaValue[0].value, "base64"))
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue