调试使用pm2运行的应用程序 [英] Debug application which is run using pm2

查看:187
本文介绍了调试使用pm2运行的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序运行

pm2 start app.js

pm2 start config.json

我想使用node_inspector在本地调试我的应用程序.我添加了debug参数

I want to debug my application locally using node_inspector. I added debug argument

pm2 start --node-args="--debug=7000" app.js

它工作正常,但是如果我提供config.json而不是脚本app.js,我不知道如何传递有关debug的参数.下一个配置不起作用

It works fine but if I provide config.json instead of script app.js I don't know how to pass arguments about debug. Next piece of config doesn't work

{
  "apps": [
    {
      "name": "myName",
      "script": "app.js",
      "args": "['--debug=7000']"
      ............
      }
    ]
}

那么如何调试由pm2运行并使用config的应用程序?

So How to debug application which is run by pm2 and using config?

推荐答案

您快到了,使用node_args代替args:

  • args是您的脚本参数
  • node_args是传递给节点可执行文件的参数

  • args are your script arguments
  • node_args are arguments that are passed to node executable

{
  "name": "myName",
  "script": "app.js",
  "node_args": ["--debug=7000"]
}

PM2 json模式.

如果此后仍然有人对调试设置有问题,则在某些情况下,您必须禁用群集模式才能使调试设置生效.

If someone still has problems with the debug setting after this, in some case you have to disable the cluster mode for the debug setting to be effective.

还请注意,如果将所有args作为单个字符串传递,则不需要在node_args值中使用括号.

Also note that you don't need the brackets in the node_args value if you pass all the args as a single string.

这篇关于调试使用pm2运行的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆