From 3183c38d2642c51befc87df3d9d6a32c20337b11 Mon Sep 17 00:00:00 2001 From: Vadim Zubkov Date: Sun, 5 Nov 2023 03:22:21 +0300 Subject: [PATCH] Add inspector to resource config --- server/src/CNodeResourceImpl.cpp | 2 +- server/src/bootstrap.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/server/src/CNodeResourceImpl.cpp b/server/src/CNodeResourceImpl.cpp index 5ac41f7d..d4eb4653 100644 --- a/server/src/CNodeResourceImpl.cpp +++ b/server/src/CNodeResourceImpl.cpp @@ -61,7 +61,7 @@ bool CNodeResourceImpl::Start() auto inspector = node::GetInspectorParentHandle(runtime->GetParentEnv(), threadId, resource->GetName().c_str()); std::vector args{ resource->GetName() }; - std::vector execArgs{ "--inspect=127.0.0.1:9229" }; + std::vector execArgs{ }; env = node::CreateEnvironment(nodeData, _context, args, execArgs, flags, threadId, std::move(inspector)); node::LoadEnvironment(env, bootstrap_code); diff --git a/server/src/bootstrap.js b/server/src/bootstrap.js index a3196f66..2beabb17 100644 --- a/server/src/bootstrap.js +++ b/server/src/bootstrap.js @@ -6,6 +6,7 @@ const path = require("path"); const alt = process._linkedBinding("alt"); const dns = require('dns'); const url = require("url"); +const inspector = require("inspector"); (async () => { const resource = alt.Resource.current; @@ -29,6 +30,15 @@ const url = require("url"); new Function("alt", "__global", __internal_bindings_code)(alt, bindingsGlobal); __setLogFunction(bindingsGlobal.genericLog); + const config = alt.Resource.current.config; + if (config.inspector) { + const host = config.inspector.host ?? '127.0.0.1'; + const port = config.inspector.port ?? 9229; + const wait = config.inspector.wait ?? false; + + inspector.open(port, host, wait); + } + const extraBootstrapFile = __getExtraBootstrapFile(); if(extraBootstrapFile.length !== 0) new Function("alt", extraBootstrapFile)(alt);