gpt4 book ai didi

mysql - 使用 MySQL 数据源将 Strongloop/Loopback 部署到 Openshift 时出错

转载 作者:行者123 更新时间:2023-11-29 02:55:11 25 4
gpt4 key购买 nike

我一直在尝试使用 MySQL 数据源应用程序将 Strongloop/Loopback 部署到 Openshift,但没有成功。以下是我遵循的步骤。

  1. 在我的 Windows 7 上安装了 Node。
  2. 是否安装了 npm -g strongloop
  3. 按照此 link 中的说明创建了一个数据源
  4. 我使用 MySQL 而不是 MongoDB。以下是我的设置。

包.json

{
"name": "loopback-app",
"version": "0.0.0",
"main": "server/server.js",
"scripts": {
"start": "slc run",
"pretest": "jshint ."
},
"dependencies": {
"compression": "^1.0.3",
"errorhandler": "^1.1.1",
"loopback": "^2.0.0",
"loopback-boot": "^2.0.0",
"loopback-connector-mysql": "^2.1.1",
"loopback-datasource-juggler": "^2.0.0",
"serve-favicon": "^2.0.1"
},
"optionalDependencies": {
"loopback-explorer": "^1.1.0"
}
}

数据源.json

{
"db": {
"name": "db",
"connector": "memory"
},
"mysql": {
"host": "mysql-openshift-db-host",
"port": mysql-openshift-db-port,
"database": "gearname",
"password": "mysql-password",
"name": "mysql",
"connector": "mysql",
"user": "mysql-username"
}
}

模型配置.json

{
"_meta": {
"sources": [
"../common/models",
"./models"
]
},
"User": {
"dataSource": "db"
},
"AccessToken": {
"dataSource": "db",
"public": false
},
"ACL": {
"dataSource": "db",
"public": false
},
"RoleMapping": {
"dataSource": "db",
"public": false
},
"Role": {
"dataSource": "db",
"public": false
},
"Demo": {
"dataSource": "mysql",
"public": true
}
}

它在我的机器上本地运行时有效。但是,将其部署到 Openshift,然后转到 http:///explorer 并为我的模型尝试其中一种方法时,出现以下错误。

==> strongloop/logs/node.log <==
2015-07-12T14:08:02.538Z pid:27006 worker:supervisor INFO strong-agent not profiling, configuration not found.
2015-07-12T14:08:02.543Z pid:27006 worker:supervisor Generate configuration with:
2015-07-12T14:08:02.545Z pid:27006 worker:supervisor npm install -g strong-cli
2015-07-12T14:08:02.545Z pid:27006 worker:supervisor slc strongops
2015-07-12T14:08:02.546Z pid:27006 worker:supervisor See http://docs.strongloop.com/strong-agent for more information.
Browse your REST API at http://localhost:3000/explorer
Web server listening at: http://localhost:3000/

assert.js:92
throw new assert.AssertionError({
^
AssertionError: options must be an object
at MySQL.SQLConnector.execute (/var/lib/openshift/55a23e52e0b8cdb70700003f/app-root/runtime/repo/node_modules/loopback-connector-mysql/node_module
s/loopback-connector/lib/sql.js:391:3)
at MySQL.find [as all] (/var/lib/openshift/55a23e52e0b8cdb70700003f/app-root/runtime/repo/node_modules/loopback-connector-mysql/node_modules/loopb
ack-connector/lib/sql.js:1051:8)
at Function.find (/var/lib/openshift/55a23e52e0b8cdb70700003f/app-root/runtime/repo/node_modules/loopback-datasource-juggler/lib/dao.js:736:34)
at SharedMethod.invoke (/var/lib/openshift/55a23e52e0b8cdb70700003f/app-root/runtime/repo/node_modules/loopback/node_modules/strong-remoting/lib/s
hared-method.js:207:17)
at HttpContext.invoke (/var/lib/openshift/55a23e52e0b8cdb70700003f/app-root/runtime/repo/node_modules/loopback/node_modules/strong-remoting/lib/ht
tp-context.js:243:12)
at /var/lib/openshift/55a23e52e0b8cdb70700003f/app-root/runtime/repo/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:475:
9
at execStack (/var/lib/openshift/55a23e52e0b8cdb70700003f/app-root/runtime/repo/node_modules/loopback/node_modules/strong-remoting/lib/remote-obje
cts.js:346:7)
at /var/lib/openshift/55a23e52e0b8cdb70700003f/app-root/runtime/repo/node_modules/loopback/lib/application.js:329:13
at /var/lib/openshift/55a23e52e0b8cdb70700003f/app-root/runtime/repo/node_modules/loopback/lib/models/model.js:267:5
at /var/lib/openshift/55a23e52e0b8cdb70700003f/app-root/runtime/repo/node_modules/loopback/lib/models/acl.js:443:19

npm info loopback-app@0.0.0 Failed to exec start script
npm ERR! loopback-app@0.0.0 start: `slc run`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the loopback-app@0.0.0 start script.
npm ERR! This is most likely a problem with the loopback-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! slc run
npm ERR! You can get their info via:
npm ERR! npm owner ls loopback-app
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 2.6.32-504.16.2.el6.x86_64
npm ERR! command "/var/lib/openshift/55a23e52e0b8cdb70700003f/strongloop//bin/node/node" "/var/lib/openshift/55a23e52e0b8cdb70700003f/strongloop/bin/n
ode/npm" "start" "-d"
npm ERR! cwd /var/lib/openshift/55a23e52e0b8cdb70700003f/app-root/runtime/repo
npm ERR! node -v v0.10.30
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /var/lib/openshift/55a23e52e0b8cdb70700003f/app-root/runtime/repo/npm-debug.log
npm ERR! not ok code 0

==> app-root/logs/haproxy.log <==
[WARNING] 192/100828 (395134) : Server express/local-gear is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms.
0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[ALERT] 192/100828 (395134) : proxy 'express' has no server available!

感谢任何帮助。

最佳答案

您的应用程序需要监听您的 openshift ip 地址和端口,它似乎仍在尝试在代码中监听 localhost:3000,您还应该确保您正在使用 mysql 环境变量连接到 mysql。以下是您应该通读的一些资源:

https://developers.openshift.com/en/node-js-overview.html https://developers.openshift.com/en/databases-mysql.html

关于mysql - 使用 MySQL 数据源将 Strongloop/Loopback 部署到 Openshift 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31368797/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com