2017-09-28 98 views
0

我有一個簡單的命令運行時正常工作:如何用參數啓動pm2?

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

我在做什麼錯?

回答

0

在指定參數的地方使用流程文件。創建以下文件並將其命名例如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

+0

是不是可以通過CLI來做到這一點?我真的不想通過json文件來做到這一點。 – az2902

+0

查看這些文檔以通過CLI執行此操作: https://futurestud.io/tutorials/pm2-how-to-start-your-app-with-node-js-v8-arguments – cody