From 2de32b19f954f0252c0b1723a4c4cb2226109239 Mon Sep 17 00:00:00 2001 From: unexp Date: Tue, 14 Feb 2023 21:52:58 -0300 Subject: [PATCH] KILL ORPHANS (Proceses xd) --- .env.example | 16 ---------------- src/lib/classes/RCCService.js | 13 ++++++++----- 2 files changed, 8 insertions(+), 21 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index a1bb39f..0000000 --- a/.env.example +++ /dev/null @@ -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 diff --git a/src/lib/classes/RCCService.js b/src/lib/classes/RCCService.js index b96e29d..d3abc81 100644 --- a/src/lib/classes/RCCService.js +++ b/src/lib/classes/RCCService.js @@ -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) @@ -48,4 +51,4 @@ class RCCService extends EventEmitter { } } -module.exports = RCCService +module.exports = RCCService \ No newline at end of file