[英]Passing JSON File to PM2 as a node argument
I have a NodeJS app which needs to start the server with the following parameter: start server.js --config=config.json
.我有一个 NodeJS 应用程序,它需要使用以下参数start server.js --config=config.json
服务器: start server.js --config=config.json
。 Then in the server.js I use NodeUtils.getArgs()
and JSON.parse()
to get all the parameters of the config.json file.然后在 server.js 中我使用NodeUtils.getArgs()
和JSON.parse()
来获取 config.json 文件的所有参数。 This works well.这很好用。
Now, I want to start the server with PM2, but I am not being able.现在,我想用 PM2 启动服务器,但我不能。
If I try with pm2 start server.js --node-args"--config=config.json"
I get a node: bad option: --config=config.json
.如果我尝试使用pm2 start server.js --node-args"--config=config.json"
我得到一个node: bad option: --config=config.json
。 I tried with a lot of options but none of them works.我尝试了很多选择,但没有一个有效。
How can I do it?我该怎么做? Thanks谢谢
EDIT: After starting pm2, if it gets an error, you must pm2 delete all
.编辑:启动 pm2 后,如果出现错误,则必须pm2 delete all
.
你可以在--
之后传递你自己的参数,所以你可以这样做:
pm2 start server.js -- -config=config.json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.