【问题标题】:How to pass the debug argument from pm2 to a node process that uses a Coffeescript interpreter?如何将调试参数从 pm2 传递到使用 Coffeescript 解释器的节点进程?
【发布时间】:2015-12-18 22:54:17
【问题描述】:

以下命令未按预期运行。调试参数未到达节点进程:

pm2 startOrRestart server.json --node-args="--debug=7001"

server.json 文件:

{
  "apps" : [
    {
      "name"             : "web",
      "cwd"              : "/home/app/",
      "instances"        : 1,
      "cron_restart"     : "*/30 * * * *",
      "script"           : "web/server.coffee",
      "exec_interpreter" : "coffee",
      "error_file"       : "logs/web-err.log",
      "out_file"         : "logs/web-out.log"
    }
  ]
}

但是pm2启动的node进程没有debug参数。

22:10   0:05 node /home/app/web/server.coffee

我怀疑这与我使用的是 Coffeescript 解释器有关。例如,如果我直接运行 Coffee 命令(绕过 pm2),我可以让事情按预期工作,这会按预期以调试模式启动节点进程:

coffee --nodejs --debug=5000 /home/app/web/server.coffee

如何正确地将调试参数从 pm2 传递到 coffee 到 node,以便它一直传递到 node 进程?

【问题讨论】:

    标签: coffeescript pm2


    【解决方案1】:

    问题可以通过在 --node-args 选项值中添加 '--nodejs' 来解决,比如

    pm2 startOrRestart server.json --node-args="--nodejs --debug=7001"
    

    如果解释器被指定为“coffee”,那么咖啡二进制文件(或咖啡脚本 npm 包)将在内部使用。所以我们必须相应地赋予 --node-args 选项值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-25
      • 2017-04-23
      • 1970-01-01
      • 2019-05-02
      • 1970-01-01
      • 2012-06-25
      • 1970-01-01
      相关资源
      最近更新 更多