node.jsparse-serverpm2parse-dashboard

How to start pm2 with arguments?


I have a simple command that works fine when run:

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

However, when running it with pm2, it doesn't work:

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

looking at the logs, i get the error: node: bad option: --config=/home/ubuntu/dash/config.json

What am I doing wrong?


Solution

  • Use a process file where you specify the arguments. Create the following file and name it for example ecosystem.json (make sure the 'script' and 'cwd' (where the app will be launched) locations are correct for you))

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

    And run it with

    pm2 start ecosystem.json