首页 > 解决方案 > 如何在 Google App Engine 上运行 ghost

问题描述

我想在 GAE 标准环境中运行 ghost。但我做不到。发生了什么?

服务器.js

const ghost = require('ghost');
const port = process.env.PORT || 8080;

ghost().then(function (ghostServer) {
    ghostServer.rootApp.listen(port);
});

错误信息

INFO This request caused a new process to be started for your application and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.

ERROR A problem was encountered with the process that handled this request, causing it to exit. This is likely to cause a new process to be used for the next request to your application. (Error code 204)

标签: node.jsgoogle-app-engineghost

解决方案


我之前收到过一次错误代码 204。就在我发现应用引擎版本的 python ssl 库中存在内存泄漏时,每隔几分钟就会使我的实例崩溃。我必须与 Google Cloud 支持部门合作才能解决这个问题。

我遇到了另一个问题,我不得不更改 python 库的源代码,因为它会尝试绑定到端口并失败。这实际上很好,因为它优雅地失败了,我试图解决的问题是它有时会挂起 10 分钟。

据此,GAE 标准上NodeJS 处于测试阶段:

这是 Google App Engine 标准环境中 Node.js 的 beta 版本。此功能可能会以向后不兼容的方式进行更改,并且不受任何 SLA 或弃用策略的约束。

所以我不会偏离他们提供的示例应用程序太远:

https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/appengine/hello-world/standard

选项

  1. 如果可能的话,坚持使用 GAE 标准上的 Express
  2. 如果您需要使用 Ghost,请考虑切换到 GAE Flex
  3. 如果您对在 GAE Standard 上使用 Ghost 很执着,请像在示例中那样使用 Express,但将其设置为 Ghost 的适配器。有一个单一的 Express 请求处理程序,将请求提供给 Ghost 并将来自 Ghost 的响应传回(事实上,这个功能请求听起来像我试图描述的内容https://github.com/TryGhost/Ghost/issues/827

推荐阅读