Skip to content

Commit ec90a7a

Browse files
ofrobotsFishrock123
authored andcommitted
inspector: change default port
We should use a different default port number for the new debug protocol. This makes it easier for debuggers to guess which protocol they are expected to use to talk to a node process with a debug server. PR-URL: #7212 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
1 parent 2fd140b commit ec90a7a

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/inspector_agent.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class V8NodeInspector : public blink::V8Inspector {
244244
bool running_nested_loop_;
245245
};
246246

247-
Agent::Agent(Environment* env) : port_(9229),
247+
Agent::Agent(Environment* env) : port_(0),
248248
wait_(false),
249249
connected_(false),
250250
shutting_down_(false),

src/node.cc

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static bool use_inspector = false;
143143
static bool use_debug_agent = false;
144144
static bool debug_wait_connect = false;
145145
static int debug_port = 5858;
146+
static int inspector_port = 9229;
146147
static const int v8_default_thread_pool_size = 4;
147148
static int v8_thread_pool_size = v8_default_thread_pool_size;
148149
static bool prof_process = false;
@@ -3436,12 +3437,17 @@ static bool ParseDebugOpt(const char* arg) {
34363437
}
34373438

34383439
if (port != nullptr) {
3439-
debug_port = atoi(port);
3440-
if (debug_port < 1024 || debug_port > 65535) {
3440+
int port_int = atoi(port);
3441+
if (port_int < 1024 || port_int > 65535) {
34413442
fprintf(stderr, "Debug port must be in range 1024 to 65535.\n");
34423443
PrintHelp();
34433444
exit(12);
34443445
}
3446+
if (use_inspector) {
3447+
inspector_port = port_int;
3448+
} else {
3449+
debug_port = port_int;
3450+
}
34453451
}
34463452

34473453
return true;
@@ -3703,22 +3709,21 @@ static void StartDebug(Environment* env, bool wait) {
37033709
CHECK(!debugger_running);
37043710
#if HAVE_INSPECTOR
37053711
if (use_inspector) {
3706-
env->inspector_agent()->Start(default_platform, debug_port, wait);
3712+
env->inspector_agent()->Start(default_platform, inspector_port, wait);
37073713
debugger_running = true;
37083714
} else {
37093715
#endif
37103716
env->debugger_agent()->set_dispatch_handler(
37113717
DispatchMessagesDebugAgentCallback);
37123718
debugger_running = env->debugger_agent()->Start(debug_port, wait);
3719+
if (debugger_running == false) {
3720+
fprintf(stderr, "Starting debugger on port %d failed\n", debug_port);
3721+
fflush(stderr);
3722+
return;
3723+
}
37133724
#if HAVE_INSPECTOR
37143725
}
37153726
#endif
3716-
3717-
if (debugger_running == false) {
3718-
fprintf(stderr, "Starting debugger on port %d failed\n", debug_port);
3719-
fflush(stderr);
3720-
return;
3721-
}
37223727
}
37233728

37243729

0 commit comments

Comments
 (0)