在正在运行的节点应用程序上启动调试会话并附加节点调试器? [英] Start debug session on running node app and attach node debugger?
问题描述
我听说过很多传闻,它们可以通过将 SIGUSR1
传递给应用程序来在正在运行的节点应用程序上创建调试会话。
I've heard a lot of rumors about being able to create a debug session on a running node application by passing SIGUSR1
to the application.
意思是我不必使用 node debug app.js
来启动应用程序以将调试器附加到它。
Meaning I don't have to start an application with node debug app.js
in order to attach a debugger to it.
如何将 SIGUSR1
发送到我的应用程序,然后将调试客户端附加到进程中?如果我可以在只有 node
的Docker容器中执行此操作,则将特别有用。
How do I send SIGUSR1
to my application and then attach a debug client to the process? It would be especially helpful if I could do this from within a Docker container with only node
.
推荐答案
如何发送 SIGUSR1
How to send SIGUSR1
- 使用
kill -l </ code>查看信号列表。
- 在我的情况下,
USR1
对应于10
。 -
ps
查找我要发送信号的过程 -
kill -10< pid>
- 调试会话现已打开
- Use
kill -l
to view a list of signals. - In my case
USR1
corresponds to10
. ps
to find the process I want to send the signal to.kill -10 <pid>
- A debug session is now open.
附加调试器。
Attaching the debugger.
-
node debug localhost:5858
node debug localhost:5858
5858
是旧式调试器的默认端口。在 node8
中,发送 USR1
将激活新的检查器
协议,
5858
is the default port for the legacy debugger. In node8
sending USR1
will activate the new inspector
protocol, but until then this is how you can start and connect the debugger on a live application.
观看此空间以获取更新:> https://nodejs.org/en/docs/guides/debugging-getting-started/
Watch this space for updates: https://nodejs.org/en/docs/guides/debugging-getting-started/
这篇关于在正在运行的节点应用程序上启动调试会话并附加节点调试器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!