简体   繁体   English

OpenShift上的Node JS应用给出错误503

[英]Node JS app on OpenShift gives error 503

So I created a NodeJS app for a college project which monitors page loading speed. 因此,我为一个大学项目创建了一个NodeJS应用程序,该应用程序监视页面加载速度。 In order to record said speed I need people to go to the web application, go to a certain page and hit a button a couple of times. 为了记录所说的速度,我需要人们去访问Web应用程序,去某个页面并按下几次按钮。

So I looked up a way to host this app, free of charge, and came up with OpenShift . 因此,我想出了一种免费托管此应用的方法,并提出了OpenShift

After figuring out how it all worked I managed to setup an OpenShift git-repository and I am able to push my changes to the server. 在弄清所有工作原理之后,我设法建立了一个OpenShift git存储库,并将更改推送到服务器上。

However upon visiting my page I kept getting error 503 . 但是,在访问我的页面时,我不断收到error 503 Initially I thought it was a node modules error so I found npm shrinkwrap which solved npm version issues. 最初,我认为这是一个节点模块错误,所以我找到了解决npm版本问题的npm shrinkwrap The error, is still around. 错误仍然存​​在。

When I run the app locally, I get no errors whatsoever and all modules are installed correctly. 在本地运行该应用程序时,没有任何错误,所有模块均已正确安装。 They are also in a package.json file (I used npm install --save for all my modules, so no manual editing was performed). 它们也位于package.json文件中(我对所有模块都使用了npm install --save ,因此没有执行手动编辑)。

These are the first couple of lines from using the tail -command and whopping the result into a text file. 这是使用tail -command并将结果大写到文本文件中的前几行。

 ==> app-root/logs/nodejs.log <==
    at Connection.connect (/var/lib/openshift/550db5624382ecf8f400000f/app>root/runtime/repo/node_modules/mysql/lib/Connection.js:109:18)
    at Object.<anonymous> (/var/lib/openshift/550db5624382ecf8f400000f/approot/runtime/repo/server.js:28:12)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
DEBUG: Program node server.js exited with code 8
DEBUG: Starting child process with 'node server.js'

I also found this: 我也发现了这一点:

 ==> app-root/logs/nodejs.log <==
Error: connect ECONNREFUSED
    at errnoException (net.js:901:11)
    at Object.afterConnect [as oncomplete] (net.js:892:19)
    --------------------
    at Protocol._enqueue (/var/lib/openshift/550db5624382ecf8f400000f/app-root/runtime/repo/node_modules/mysql/lib/protocol/Protocol.js:135:48)
    at Protocol.handshake (/var/lib/openshift/550db5624382ecf8f400000f/app-root/runtime/repo/node_modules/mysql/lib/protocol/Protocol.js:52:41)
    at Connection.connect (/var/lib/openshift/550db5624382ecf8f400000f/app-root/runtime/repo/node_modules/mysql/lib/Connection.js:109:18)
    at Object.<anonymous> (/var/lib/openshift/550db5624382ecf8f400000f/app-root/runtime/repo/server.js:28:12)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
DEBUG: Program node server.js exited with code 8

Any idea's? 有任何想法吗?

Mine did the same when I first pushed to OpenShift. 我刚开始使用OpenShift时,我的操作也是如此。 I think I had to review some references and make some slight changes. 我想我必须复习一些参考资料并进行一些细微的更改。 My log on OpenShift indicated that such-and-such file couldn't be found. 我在OpenShift上的日志表明找不到该文件。 Yours might, too, if you review the entire thing. 如果您回顾整个过程,您也可能会这样做。

For example, this is the "after" version of something I edited: 例如,这是我编辑的内容的“之后”版本:

        self.app.set('views', path.join(__dirname, 'views'));

I might have had just this before: 我可能以前有过:

        self.app.set('views', '/views');

Hope that helps. 希望能有所帮助。

Well... you've got... 嗯...你有...

Error: connect ECONNREFUSED

...which suggests that Express couldn't connect to the database. ...这表示Express无法连接到数据库。 Maybe you've got dev versus prod credentials going on and the code's trying to use the local credentials, the local database name, the local username, the local server, etc. 也许您正在使用开发凭证和产品凭证,并且代码正在尝试使用本地凭证,本地数据库名称,本地用户名,本地服务器等。

I'm using MongoDB (no credentials locally) and have created a /db.js file to store all that. 我正在使用MongoDB(本地没有凭据),并创建了一个/db.js文件来存储所有内容。 And then my /server.js selects which variable: 然后,我的/server.js选择哪个变量:

if (typeof process.env.OPENSHIFT_NODEJS_IP === "undefined") { mongoose.connect(dbConfig.devurl); } else { mongoose.connect(dbConfig.produrl); }

Note the two different variables after dbConfig.varname. 注意dbConfig.varname之后的两个不同变量。

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

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