Node.js Openshift应用程序部署的代码不起作用 [英] Nodejs openshift app deployed code not working

查看:88
本文介绍了Node.js Openshift应用程序部署的代码不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用nodejs应用程序,我编写了服务器侦听代码,然后将代码部署到了openshift托管中,我得到了503响应,如果在本地运行此代码,则它可以正常工作.

I am working on nodejs app,i wrote server listening code,then i deployed code into openshift hosting,there i am getting 503 response,in local if i run this code it is properly working.

代码:

var http = require('http');
var express = require('express');
var fs      = require('fs');


var app = express();
app.set('port', process.env.OPENSHIFT_NODEJS_PORT || 8080);
app.set('ip', process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1');

http.createServer(app).listen(app.get('port'), app.get('ip'), function(){
    console.log('Express server listening on port ' + app.get('port'));
});

app.get('/', function (req, res) {
    res.send('Hello World!');
});

推荐答案

是否传递OPENSHIFT_NODEJS_IP变量? 通常的问题是,在这种情况下,nodejs应用程序正在IP 127.0.0.1上侦听,但应该在0.0.0.0上侦听. 如果这样做没有帮助,请提供更多有关如何在OpenShift中创建应用程序的详细信息.

Do you pass the OPENSHIFT_NODEJS_IP variable? Quite often the problem is that the nodejs application is listening on IP 127.0.0.1 like in this case, but should on 0.0.0.0. If that doesn't help please provide more details on how you created the application in OpenShift.

这篇关于Node.js Openshift应用程序部署的代码不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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