应用程序无法启动(端口8080)不可用

我正在尝试将我的node.js应用程序(带有express和mongoose)部署到openshift上,但我无法这样做。该应用程序可以在我的本地环境中完美运行。

我的入口是文件/ bin / www

我将它作为package.json文件中此行的openshift入口点

"main": "bin/www",

我已经确保按照指南使用环境变量设置mongodb连接,如下所示:

// default to a localhost configuration:

var mongoConnectionString = 'mongodb://127.0.0.1/code-blog';

// if OPENSHIFT env variables are present, use the available connection info:

if (process.env.OPENSHIFT_MONGODB_DB_PASSWORD) {

mongoConnectionString = process.env.OPENSHIFT_MONGODB_DB_USERNAME + ":" +

process.env.OPENSHIFT_MONGODB_DB_PASSWORD + "@" +

process.env.OPENSHIFT_MONGODB_DB_HOST + ':' +

process.env.OPENSHIFT_MONGODB_DB_PORT + '/' +

process.env.OPENSHIFT_APP_NAME;

}

mongoose.connect(mongoConnectionString);

我得到的错误是:

remote: Waiting for application port (8080) become available ...

remote: Application 'codeblog' failed to start (port 8080 not available)

remote: -------------------------

remote: Git Post-Receive Result: failure

remote: Activation status: failure

remote: Activation failed for the following gears:

remote: 558a25bd5973ca7a74000162 (Error activating gear: CLIENT_ERROR: Failed to

execute: 'control start' for /var/lib/openshift/558a25bd5973ca7a74000162/nodejs

remote: #<IO:0x00000000b49380>

remote: #<IO:0x00000000b49308>

remote: )

remote: Deployment completed with status: failure

remote: postreceive failed

To ssh://558a25bd5973ca7a74000162@codeblog-donaldsubert.rhcloud.com/~/git/codebl

og.git/

29635a8..7a0e926 master -> master

这对我来说很奇怪,因为我没有在任何地方指定端口8080。实际上,默认端口在此处指定:

var port = normalizePort(process.env.OPENSHIFT_NODEJS_PORT || "3000");

var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1";

app.set('port', port);

var server = http.createServer(app);

我不太确定从这里到哪里。我似乎没有足够的信息来确定下一步。

[edit]我添加了一些日志记录以测试该端口在哪个端口上运行,但是该日志记录语句永远不会运行。这是代码

console.log("TEST TEST TEST");

var app = require('../app');

var debug = require('debug')('ProjectTemplate:server');

var http = require('http');

var port = normalizePort(process.env.OPENSHIFT_NODEJS_PORT || "3000");

var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1";

console.log("PORT: ", port);

和输出

TEST TEST TEST

module.js:340

throw err;

^

Error: Cannot find module './routes/logIn'

at Function.Module._resolveFilename (module.js:338:15)

at Function.Module._load (module.js:280:25)

at Module.require (module.js:364:17)

at require (module.js:380:17)

at Object.<anonymous> (/var/lib/openshift/558a25bd5973ca7a74000162/app-root/ runtime/repo/app.js:26:13)

TEST TEST TEST来自入口点文件开头的日志记录语句。似乎在命中之前就失败了。console.log("PORT: ",

port);这很可能与app.js建立MongoDb连接有关。

[/编辑]

回答:

该错误原来是与端口无关的一般性错误。显然,如果出现致命的JavaScript错误,它会显示此消息。

以上是 应用程序无法启动(端口8080)不可用 的全部内容, 来源链接: utcz.com/qa/421655.html

回到顶部