【发布时间】:2020-11-12 18:59:03
【问题描述】:
我尝试以编程方式使用 PM2 将参数传递给我的脚本
pm2.start('./MyScript.js', {
name: MyScript,
script: './MyScript.js',
exec_mode : "cluster",
instances: 1,
args : '-- MyArg1 MyArg2',
}, function(err, apps) {
pm2.disconnect();
if (err) throw err
});
在“MyScript1”中,我只是打印命令行参数
console.log('Script started with process.argv \'' + process.argv + '\'');
return(0);
结果总是
Script started with process.argv 'C:\Program Files (x86)\nodejs\node.exe,C:\Workspace\..\node_modules\pm2\lib\ProcessContainer.js'
如果我使用'--node-args',我会得到相同的结果
知道有什么问题吗?
【问题讨论】: