使用pm2将环境变量传递给node.js [英] Passing environment variables to node.js using pm2

查看:1570
本文介绍了使用pm2将环境变量传递给node.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将一些参数传递给由pm2运行的Express应用程序.他们的文档中没有任何提示,但显然可以将某些EV传递给您的节点应用程序,例如SOME_STUFF=xxx pm2 start app.js.

I am trying to pass some arguments to my Express application which is run by pm2. There wasn't any hint in their documentation to do so, but apparently it's possible to pass some EV to your node application like SOME_STUFF=xxx pm2 start app.js.

推荐答案

实际上是有可能的,我很确定它早在PM2的文档中.

It's actually possible and I'm pretty sure it was in PM2's documentation some time ago.

无论如何,这就是您需要做的:

Anyways, that's what you need to do:

pm2 start app.js -- -some_stuff xxx

基本上,添加--,然后您可以添加自己的应用程序参数.

Basically, add -- and then you can add your own app parameters.

设法找到源,它被很好地隐藏了: http://pm2.keymetrics.io/docs/usage/quick-start/#42-ways-of-starting-processes

Managed to find the source, it was hidden quite well: http://pm2.keymetrics.io/docs/usage/quick-start/#42-ways-of-starting-processes

这篇关于使用pm2将环境变量传递给node.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆