【问题标题】:KeystoneJS app failing to deploy on Google App EngineKeystoneJS 应用程序无法在 Google App Engine 上部署
【发布时间】:2019-01-02 06:53:28
【问题描述】:

我在 Google Compute Engine 实例上有一个 KeystoneJS 应用,在我的项目文件夹中执行 mongod 和 npm start 后,我​​运行 gcloud app deploy 并收到以下错误:

Mongoose connection "error" event fired with:
{ MongoError: failed to connect to server [localhost:27017] on first connect
at Pool.<anonymous> (/app/node_modules/mongodb-core/lib/topologies/server.js:326:35)
at Pool.emit (events.js:182:13)
at Connection.<anonymous> (/app/node_modules/mongodb-core/lib/connection/pool.js:272:12)
at Object.onceWrapper (events.js:273:13)
at Connection.emit (events.js:182:13)
at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:175:49)
at Object.onceWrapper (events.js:273:13)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
name: 'MongoError',
message:
'failed to connect to server [localhost:27017] on first connect' }
Error: KeystoneJS (Modern Marketing) failed to start - Check that you are running `mongod` in a separate process.
at NativeConnection.<anonymous> (/app/node_modules/keystone/lib/core/openDatabaseConnection.js:59:10)
at NativeConnection.emit (events.js:182:13)
at Immediate.<anonymous> (/app/node_modules/mongoose/lib/connection.js:296:19)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! modern-marketing@0.0.0 start: `node keystone.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the modern-marketing@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-01-02T05_59_39_493Z-debug.log

我没有太多使用 MongoDB 或 KeystoneJS 的经验,因此感谢任何见解

【问题讨论】:

  • 您在 Compute Engine 上说它,但您正在运行 App Engine 命令。你能澄清一下你实际使用的是什么产品吗?它们是两种截然不同的产品。

标签: node.js mongodb google-app-engine google-compute-engine keystonejs


【解决方案1】:

似乎在部署到 GAE 时,您会保持与本地托管 mongo 数据库的默认连接。 (failed to connect to server [localhost:27017])

由于 GAE 环境没有运行 mongodb,您必须创建一个 mongo 数据库(您可以在这里使用许多不同的 mongodb 服务)并使用 MONGO_URI 环境变量设置您的项目。

Keystonejs 将尝试连接您在此变量中设置的数据库。

我希望此评论对您有所帮助,如果您在设置所有这些内容时仍有一些问题,您可以向我们展示您的 app.yaml 文件;)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-22
    • 2019-05-18
    • 2014-03-30
    • 2012-02-11
    • 2023-03-06
    • 2019-08-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多