KILL ORPHANS (Proceses xd)

This commit is contained in:
unexp 2023-02-14 21:52:58 -03:00
parent e00266ff18
commit 2de32b19f9
No known key found for this signature in database
GPG Key ID: BF66F09641C584C8
2 changed files with 8 additions and 21 deletions

View File

@ -1,16 +0,0 @@
RCCSERVICE=
ARBITER_TOKEN=
BASE_URL=https://sitetest.unexp.xyz
RENDER_FORMAT=PNG
RENDER_BASE64=
RENDER_USER_WIDTH=720
RENDER_USER_HEIGHT=720
RENDER_ASSET_WIDTH=720
RENDER_ASSET_HEIGHT=720
RENDER_PLACE_WIDTH=854
RENDER_PLACE_HEIGHT=480

View File

@ -5,6 +5,8 @@ const waitPort = require("wait-port")
const logger = require("../../lib/logger.js")
const randport = require("../../lib/randport.js")
const chalk = require('chalk')
class RCCService extends EventEmitter {
constructor() {
super()
@ -22,10 +24,11 @@ class RCCService extends EventEmitter {
}
this.proc.once("spawn", async () => {
logger.info(`[${this.port}] RCCService instance spawned`)
logger.info(`${chalk.gray(`[${this.port}]`)} RCCService instance spawned`)
const { open } = await waitPort({ host: "127.0.0.1", port: this.port, timeout: 5000, output: "silent" }).catch((e) => console.log(e))
if (!open || this.proc.exitCode !== null) {
logger.error(`[${this.port}] RCCService could not listen`)
this.proc.kill()
logger.error(`${chalk.gray(`[${this.port}]`)} RCCService could not listen`)
return resolve(false)
}
@ -33,8 +36,8 @@ class RCCService extends EventEmitter {
})
this.proc.once("exit", () => {
this.proc = null
logger.info(`[${this.port}] RCCService instance exited`)
this.proc.kill()
logger.info(`${chalk.gray(`[${this.port}]`)} RCCService instance exited`)
})
} catch (_) {
resolve(false)