如何修复 openshift 中解析服务器的 8080 端口不可用错误

How to fix 8080 port unavailable error for parse-server in openshift

我正在将我的数据后端从 parse.com 迁移到 openshift。
第 1 步。我将项目的openshift端口绑定更改为以下

//var port = process.env.PORT || 1337;
 var port = parseInt(process.env.OPENSHIFT_NODEJS_PORT) || 8080;
var httpServer = http.createServer(app);
httpServer.listen(port, function() {
  console.log('parse-server-example running on port ' + port + '.');
});

并成为我的新仓库 https://github.com/kyawzinsoe/parse-server-example.git

第 2 步。 然后我使用以下命令用我的解析服务器存储库创建一个齿轮。 rhc app-create myserver nodejs-0.10 mongodb-2 --from-code=https://github.com/kyawzinsoe/parse-server-example.git
但是显示8080端口问题如下

我错过了什么?请帮助我。

您需要将 Node 4.1+ 与解析服务器一起使用。 OpenShift 运行宁 0.10.x

您可以使用此存储库 https://github.com/h4t0n/nodejs-4-lts-openshift 以便 运行 在您的 OpenShift 应用程序上安装 Node 4.1+。

更新:

我已经设置了一个部署到 OpenShift 按钮,它将为您完成大部分工作:

您仍然需要通过编辑 index.js 文件或使用 rhc env set APP_ID=myAppId MASTER_KEY=myMasterKey -a myAppName

来设置 "appId" 和 "masterKey"

这就是您可以使用 rhc 工具做同样事情的方法:

rhc app create parseaio http://cartreflect-claytondev.rhcloud.com/github/icflorescu/openshift-cartridge-nodejs http://cartreflect-claytondev.rhcloud.com/github/icflorescu/openshift-cartridge-mongodb --from-code https://github.com/antt001/parse-server-example --env APP_ID=myAppId MASTER_KEY=myMasterKey

for more in-depth instructions, check out my blog post on this topic

原回答

  1. 使用来自 http://github.com/icflorescu/openshift-cartridge-nodejs 的墨盒创建应用程序 将 Github 页面中的 url 粘贴到应用程序创建页面底部的 "Code Anything" 文本框中 选择一种应用程序页面。
  2. 在下一页将 https://github.com/antt001/parse-server-example 粘贴到源代码文本框中,以抓取解析示例项目,针对 openshift 设置进行修改
  3. 按照 http://github.com/icflorescu/openshift-cartridge-mongodb
  4. 中的说明添加最近的 MongoDB 个墨盒
  5. 从 OpenShift 克隆您的存储库
  6. 用您的应用 ID 和密钥替换 index.js 文件中的 "appId" 和 "masterKey" 值。

没问题,我现在就是运行这个配置

更新 2

我已删除该代码段,因为它现在位于我上面提到的 GitHub 存储库中。

P.S.

如@radzio 所述,编译需要 GCC 4.8 的本机 nodejs 存在问题,但是,此配置不需要任何这些并且按原样工作,它使用 bcrypt-nodejs 而不是本机

感谢@ionut-cristian-florescu 定制墨盒

@Jiri Fiala 的评论解决了我的问题,我需要设置 openshift IP