Debugging a Running Nodejs Process In Vagrant
Software Contributor Documentation Table of Contents
There are some cases where you’d like to debug a running nodejs process running on a vagrant node.
This guide will walk through that process.
Once the process is in debug mode, Connections are possible via the browser or cli.
Browser
-
Put the process into debug mode by sending a
USR1
signal:systemctl kill -s SIGUSR1 SERVICE_NAME_HERE
-
Install
node-inspector
on the vagrant node.npm i -g node-inspector
-
start
node-inspector
:node-inspector
-
On the host, connect to
node-inspector
using the ip address the vagrant node is running on (likely 0.0.0.0) and the port node-inspector has started on (likely 8080) using chrome. -
This should load the app in an old version of devtools and will halt the code at first execution.
CLI
-
Put the process into debug mode by sending a
USR1
signal:systemctl kill -s SIGUSR1 SERVICE_NAME_HERE
-
Get the status output of the main service and note the main PID.
systemctl status SERVICE_NAME_HERE
-
Start the debugger
node debug -p PID_HERE