I am trying to deploy a NodeJS app to OpenShift and although all the deployment seems to function correctly and it looks like it's running, it seems like it's listening to the incorrect IP.
我正在尝试将NodeJS应用程序部署到OpenShift,虽然所有部署似乎都正常运行并且看起来它正在运行,但它似乎正在侦听错误的IP。
Every single tutorial instructs me to listen to process.env.OPENSHIFT_NODEJS_IP
but using console.log I discovered that this variable is not set.
每个教程都指示我监听process.env.OPENSHIFT_NODEJS_IP但是使用console.log我发现没有设置此变量。
NodeJS Openshift official example starting point uses it:
NodeJS Openshift官方示例起点使用它:
https://github.com/openshift/nodejs-ex/blob/master/server.js
https://github.com/openshift/nodejs-ex/blob/master/server.js
Another question on this subject suggests the same: Nodejs openshift app deployed code not working
关于这个主题的另一个问题表明相同:Nodejs openshift应用程序部署的代码不起作用
Anyone who has used OpenShift 3 knows why I can't find the IP address/why those supposedly globally available/default environment variables are not available and how to fix this?
任何使用过OpenShift 3的人都知道为什么我找不到IP地址/为什么那些所谓的全局可用/默认环境变量不可用以及如何解决这个问题?
1 个解决方案
#1
0
We are using NodeJS in OSE 3.2 and OCP 3.5, the only thing I could think of which we actively set was the port to listen to in the deployment configuration.
我们在OSE 3.2和OCP 3.5中使用NodeJS,我唯一能想到的是我们主动设置的是在部署配置中侦听的端口。
name: http
containerPort: 8082
protocol: TCP
This is under containers -> ports
这是在容器 - >端口下
Otherwise we haven't done anything actively. Our build is using the Docker-strategy with a Docker-file but it doesn't specify anything about IPs or Ports to open up.
否则我们没有做任何积极的事情。我们的构建使用Docker-strategy和Docker文件,但它没有指定任何关于要打开的IP或端口的信息。
#1
0
We are using NodeJS in OSE 3.2 and OCP 3.5, the only thing I could think of which we actively set was the port to listen to in the deployment configuration.
我们在OSE 3.2和OCP 3.5中使用NodeJS,我唯一能想到的是我们主动设置的是在部署配置中侦听的端口。
name: http
containerPort: 8082
protocol: TCP
This is under containers -> ports
这是在容器 - >端口下
Otherwise we haven't done anything actively. Our build is using the Docker-strategy with a Docker-file but it doesn't specify anything about IPs or Ports to open up.
否则我们没有做任何积极的事情。我们的构建使用Docker-strategy和Docker文件,但它没有指定任何关于要打开的IP或端口的信息。