Browse Source

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: https://github.com/nodejs/node/pull/7212
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
v7.x
Ali Ijaz Sheikh 9 years ago
parent
commit
a766ebf594
  1. 2
      src/inspector_agent.cc
  2. 19
      src/node.cc

2
src/inspector_agent.cc

@ -244,7 +244,7 @@ class V8NodeInspector : public blink::V8Inspector {
bool running_nested_loop_; bool running_nested_loop_;
}; };
Agent::Agent(Environment* env) : port_(9229), Agent::Agent(Environment* env) : port_(0),
wait_(false), wait_(false),
connected_(false), connected_(false),
shutting_down_(false), shutting_down_(false),

19
src/node.cc

@ -142,6 +142,7 @@ static bool use_inspector = false;
static bool use_debug_agent = false; static bool use_debug_agent = false;
static bool debug_wait_connect = false; static bool debug_wait_connect = false;
static int debug_port = 5858; static int debug_port = 5858;
static int inspector_port = 9229;
static const int v8_default_thread_pool_size = 4; static const int v8_default_thread_pool_size = 4;
static int v8_thread_pool_size = v8_default_thread_pool_size; static int v8_thread_pool_size = v8_default_thread_pool_size;
static bool prof_process = false; static bool prof_process = false;
@ -3351,12 +3352,17 @@ static bool ParseDebugOpt(const char* arg) {
} }
if (port != nullptr) { if (port != nullptr) {
debug_port = atoi(port); int port_int = atoi(port);
if (debug_port < 1024 || debug_port > 65535) { if (port_int < 1024 || port_int > 65535) {
fprintf(stderr, "Debug port must be in range 1024 to 65535.\n"); fprintf(stderr, "Debug port must be in range 1024 to 65535.\n");
PrintHelp(); PrintHelp();
exit(12); exit(12);
} }
if (use_inspector) {
inspector_port = port_int;
} else {
debug_port = port_int;
}
} }
return true; return true;
@ -3618,22 +3624,21 @@ static void StartDebug(Environment* env, bool wait) {
CHECK(!debugger_running); CHECK(!debugger_running);
#if HAVE_INSPECTOR #if HAVE_INSPECTOR
if (use_inspector) { if (use_inspector) {
env->inspector_agent()->Start(default_platform, debug_port, wait); env->inspector_agent()->Start(default_platform, inspector_port, wait);
debugger_running = true; debugger_running = true;
} else { } else {
#endif #endif
env->debugger_agent()->set_dispatch_handler( env->debugger_agent()->set_dispatch_handler(
DispatchMessagesDebugAgentCallback); DispatchMessagesDebugAgentCallback);
debugger_running = env->debugger_agent()->Start(debug_port, wait); debugger_running = env->debugger_agent()->Start(debug_port, wait);
#if HAVE_INSPECTOR
}
#endif
if (debugger_running == false) { if (debugger_running == false) {
fprintf(stderr, "Starting debugger on port %d failed\n", debug_port); fprintf(stderr, "Starting debugger on port %d failed\n", debug_port);
fflush(stderr); fflush(stderr);
return; return;
} }
#if HAVE_INSPECTOR
}
#endif
} }

Loading…
Cancel
Save