Is it possible to debug a currently running production Node application?

久未见 提交于 2019-12-20 14:43:18

问题


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:

  1. 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.
  2. 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 like ps aux | grep node.)
  3. Make sure port 8080 is exposed to your local machine from your production machine.
  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!