Skip to content

Commit

Permalink
Add inspector to resource config
Browse files Browse the repository at this point in the history
  • Loading branch information
vadzz-dev committed Nov 5, 2023
1 parent 07f6907 commit 3183c38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/src/CNodeResourceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool CNodeResourceImpl::Start()
auto inspector = node::GetInspectorParentHandle(runtime->GetParentEnv(), threadId, resource->GetName().c_str());

std::vector<std::string> args{ resource->GetName() };
std::vector<std::string> execArgs{ "--inspect=127.0.0.1:9229" };
std::vector<std::string> execArgs{ };

env = node::CreateEnvironment(nodeData, _context, args, execArgs, flags, threadId, std::move(inspector));
node::LoadEnvironment(env, bootstrap_code);
Expand Down
10 changes: 10 additions & 0 deletions server/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down

0 comments on commit 3183c38

Please sign in to comment.