2

I'm using the Wercker Continuous Integration & Delivery Platform to test and deploy a BitBucket repository on a node.js OpenShift server. Wercker loads in the BitBucket repository, builds it, tests it in the node.js environment, and passes it without any issue. It's also checking the code with jsHint, and returns without any errors.

Wercker also indicates that the deployment passes without errors, as does OpenShift. The problem is that when I check the application URL provided to me by OpenShift, it results with a server error:

503 Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

In troubleshooting this, I restarted the server (I'm running the basic account, and I have that option) but that doesn't seem to resolve the issue. Neither Wercker or Openshift indicate that there is a problem, but for some reason, I'm simply unable to access that domain without error.

How can I fix this (with the most basic tier)?

4

2 回答 2

3

这是解决方案:

我安装了 OpenShift 网站上提供的 RHC 客户端工具,检查了应用程序日志,发现 OpenShift 无法在根目录中找到 server.js 文件。因此,我将 app.js 文件重命名为 server.js,并在 package.json 中将“start”值更改为 server.js。然后我将 server.js 文件中的代码配置到 OpenShift 环境变量中,然后就完成了!

server.js 现在读取:

var http = require('http');
var ip = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1',
    port = process.env.OPENSHIFT_NODEJS_PORT || '8080';

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(port, ip);
console.log('Server running at http://'+ip+':'+port+'/');

我现在能够连接到应用程序 URL 并获得基本的“Hello World”响应。

(如果此时您仍然无法连接到您的应用程序,请重新启动您的服务器,这应该可以解决问题。)

我希望这对将来的其他人有所帮助。

这是我依靠的有用资源:https ://gist.github.com/ryanj/5267357

于 2014-05-20T20:29:34.863 回答
1

您的应用应该能够监听 Openshift 的反向代理定义的 IP 和端口。

您需要更改端口号,可能还需要更改服务器配置中的 IP。

此处解释:OpenShift node.js 错误:监听 EACCES

于 2014-05-20T18:47:49.713 回答