问题
Locally I debug by running node --debug
and using the node-inspector
tool. node-inspector must be running in the background, then I point my browser (not all browsers work; Chrome does) to http://127.0.0.1:8080/debug?port=5858
to debug.
Problem is I can't run a production server locally (missing private key files that don't belong on a dev machine), making it very hard to debug certain production problems, even if I'm willing to hack on a production machine. Is this still possible with Node inspector?
回答1:
Yes, you just need to follow a few steps from node inspector's README:
- node-inspector has to be running on the machine with the node process you are trying to debug. So, you must be able to install this there.
- Presumably your production process did not start with the
--debug
flag. You can send a signal to achieve this though:kill -s USR1 <pid>
. (pid can be obtained with something likeps aux | grep node
.) - Make sure port 8080 is exposed to your local machine from your production machine.
- Point your browser as normal; you're all set up.
来源:https://stackoverflow.com/questions/18392900/is-it-possible-to-debug-a-currently-running-production-node-application