【问题标题】:How to start pm2 with arguments?如何使用参数启动 pm2?
【发布时间】:2017-09-28 21:16:25
【问题描述】:

我有一个运行良好的简单命令:

parse-dashboard --config /home/ubuntu/dash/config.json

但是,当使用 pm2 运行它时,它不起作用:

pm2 start parse-dashboard -- --config=/home/ubuntu/dash/config.json

查看日志,我收到错误消息: node: bad option: --config=/home/ubuntu/dash/config.json

我做错了什么?

【问题讨论】:

    标签: node.js parse-server pm2 parse-dashboard


    【解决方案1】:

    使用您指定参数的过程文件。创建以下文件并将其命名为例如ecosystem.json(确保“脚本”和“cwd”(应用程序将在其中启动)位置对您来说是正确的)

    {
      "apps" : [{
        "name"        : "parse-dashboard-wrapper",
        "script"      : "/usr/bin/parse-dashboard",
        "watch"       : true,
        "cwd"         : "/home/parse/parse-dashboard",
        "args"        : "--config /home/ubuntu/dash/config.json"
      }]
    }
    

    然后运行它

    pm2 start ecosystem.json

    【讨论】:

    • 不能通过 CLI 做到这一点吗?我真的不想通过 json 文件来做到这一点。
    • 查看这些文档以通过 CLI 进行操作:futurestud.io/tutorials/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 2016-12-10
    • 1970-01-01
    • 2018-02-17
    • 1970-01-01
    • 1970-01-01
    • 2019-10-30
    相关资源
    最近更新 更多