Skip to content

Commit a766ebf

Browse files
committed
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 <[email protected]> Reviewed-By: cjihrig - Colin Ihrig <[email protected]>
1 parent 853b845 commit a766ebf

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
@@ -142,6 +142,7 @@ static bool use_inspector = false;
142142
static bool use_debug_agent = false;
143143
static bool debug_wait_connect = false;
144144
static int debug_port = 5858;
145+
static int inspector_port = 9229;
145146
static const int v8_default_thread_pool_size = 4;
146147
static int v8_thread_pool_size = v8_default_thread_pool_size;
147148
static bool prof_process = false;
@@ -3351,12 +3352,17 @@ static bool ParseDebugOpt(const char* arg) {
33513352
}
33523353

33533354
if (port != nullptr) {
3354-
debug_port = atoi(port);
3355-
if (debug_port < 1024 || debug_port > 65535) {
3355+
int port_int = atoi(port);
3356+
if (port_int < 1024 || port_int > 65535) {
33563357
fprintf(stderr, "Debug port must be in range 1024 to 65535.\n");
33573358
PrintHelp();
33583359
exit(12);
33593360
}
3361+
if (use_inspector) {
3362+
inspector_port = port_int;
3363+
} else {
3364+
debug_port = port_int;
3365+
}
33603366
}
33613367

33623368
return true;
@@ -3618,22 +3624,21 @@ static void StartDebug(Environment* env, bool wait) {
36183624
CHECK(!debugger_running);
36193625
#if HAVE_INSPECTOR
36203626
if (use_inspector) {
3621-
env->inspector_agent()->Start(default_platform, debug_port, wait);
3627+
env->inspector_agent()->Start(default_platform, inspector_port, wait);
36223628
debugger_running = true;
36233629
} else {
36243630
#endif
36253631
env->debugger_agent()->set_dispatch_handler(
36263632
DispatchMessagesDebugAgentCallback);
36273633
debugger_running = env->debugger_agent()->Start(debug_port, wait);
3634+
if (debugger_running == false) {
3635+
fprintf(stderr, "Starting debugger on port %d failed\n", debug_port);
3636+
fflush(stderr);
3637+
return;
3638+
}
36283639
#if HAVE_INSPECTOR
36293640
}
36303641
#endif
3631-
3632-
if (debugger_running == false) {
3633-
fprintf(stderr, "Starting debugger on port %d failed\n", debug_port);
3634-
fflush(stderr);
3635-
return;
3636-
}
36373642
}
36383643

36393644

0 commit comments

Comments
 (0)