在openshift上部署Mongodb和Loopback

时间:2015-08-02 11:29:47

标签: node.js openshift loopbackjs

我正在将我的第一个环回应用程序部署到Openshift。但它没有用。我创建了一个datasources.local.js文件。并做了一些改变。

datasources.local.js

module.exports = {
  myDB: {
    connector: 'loopback-connector-mongodb',
    host: 'mongodb://$OPENSHIFT_MONGODB_DB_HOST',
    port: '$OPENSHIFT_MONGODB_DB_PORT',
    database: 'even3co',
    username: 'admin',
    password: 'ZWQbMQpvMz-F'
 }
};

模型config.json

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "loopback/server/mixins",
      "../common/mixins",
      "./mixins"
    ]
  },
  "User": {
    "dataSource": "db"
  },
  "AccessToken": {
    "dataSource": "db",
    "public": false
  },
  "ACL": {
    "dataSource": "db",
    "public": false
  },
  "RoleMapping": {
    "dataSource": "db",
    "public": false
  },
  "Role": {
    "dataSource": "db",
    "public": false
  },
  "Account": {
    "dataSource": "myDB",
    "public": true
  }
}

datasources.json

{
  "db": {
    "name": "db",
    "connector": "memory"
  },
  "myFile": {
    "name": "myFile",
    "connector": "loopback-component-storage",
    "provider": "filesystem",
    "root": "./server/storage"
  }
}

并且rhc tail显示错误消息

  

帐户正在引用不存在的dataSource:“myDB”

这不是正确的方法吗?

1 个答案:

答案 0 :(得分:1)

我通过将loopback-boot升级到版本2.9.0解决了这个问题。问题在于loopback-boot版本2.6.5并且必须修改连接URL。