简体   繁体   English

在PM2中传递和读取参数

[英]Passing and Reading Parameters in PM2

I want to pass command line arguments to my script. 我想将命令行参数传递给脚本。 In forever I used to pass arguments like 我曾经永远传递诸如

forever start example.js 8080

I am unable to figure out how to do it in PM2. 我无法弄清楚如何在PM2中做到这一点。 I tried 我试过了

pm2 start KratosReq.js  -- -p 8080

but while reading from process.argv, the array contains 但是当从process.argv读取时,数组包含

[ 'node', '/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js' ]

Pm2 wrap your init script and fork node processes(cluster mode) , i think that is why you have that output , looking for declare enviroment variables in pm2 , you can use a json file to start up your server , or you can just start passing --node-args argument(checking pm2 help , there is that argument) , something like : pm2包装您的init脚本和fork节点进程(集群模式),我认为这就是为什么您有该输出, 在pm2中查找声明环境变量 ,您可以使用json文件来启动服务器,也可以只是开始传递--node-args参数(检查pm2 help,有该参数),类似:

pm2 start KratosReq.js  --node-args="-p=8080"

Hope this could help. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM