Skip to content

Instantly share code, notes, and snippets.

@sergibondarenko
Last active April 28, 2016 14:53
Show Gist options
  • Save sergibondarenko/ce45b58500a7d9290e839427a7ab8b5b to your computer and use it in GitHub Desktop.
Save sergibondarenko/ce45b58500a7d9290e839427a7ab8b5b to your computer and use it in GitHub Desktop.
Debug Kibana backend Node.js code.
# First breakpoint.
Write `debugger;` on a new line before the piece of code you want to debug.
# Run Kibi with debug option
## 1st way.
NODE_OPTIONS=--debug bin/kibi --dev
## 2nd way.
If you want to break before starting:
NODE_OPTIONS="--debug --debug-brk" bin/kibi --dev
## 3rd way.
Alternatively, you can set the same variable when calling npm start:
NODE_OPTIONS=--debug npm start
You will see:
Debugger listening on port 5858
...
# Run the debugger console
You can then use the node inspector by running `node-inspector` in a separate terminal and opening http://127.0.0.1:8080/debug?port=5858.
!!! Attention. Port 5858 could changed to other port. Look for the correct debug port in the terminal output during Kibi load.
For example, `Debugger listening on port 5861`.
Wait for 2-4 minutes before the debugger console is loaded. It will break on the `debugger;` line.
Now, you can add new breakpoints directly via the debugger console web interface. For it, click right mouse button on a line number, then select `Add Breakpoint`.
# Debug on a remote server
If you are debugging a remote server, you can either run node-inspector on the server and forward port 8080 through SSH, or you can run node-inspector locally and forward port 5858 through SSH.
http://stackoverflow.com/questions/36899554/debugging-kibana-backend-node-js-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment