node.js - 如何在 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)
解决方案
我之前收到过一次错误代码 204。就在我发现应用引擎版本的 python ssl 库中存在内存泄漏时,每隔几分钟就会使我的实例崩溃。我必须与 Google Cloud 支持部门合作才能解决这个问题。
我遇到了另一个问题,我不得不更改 python 库的源代码,因为它会尝试绑定到端口并失败。这实际上很好,因为它优雅地失败了,我试图解决的问题是它有时会挂起 10 分钟。
据此,GAE 标准上的NodeJS 处于测试阶段:
这是 Google App Engine 标准环境中 Node.js 的 beta 版本。此功能可能会以向后不兼容的方式进行更改,并且不受任何 SLA 或弃用策略的约束。
所以我不会偏离他们提供的示例应用程序太远:
选项
- 如果可能的话,坚持使用 GAE 标准上的 Express
- 如果您需要使用 Ghost,请考虑切换到 GAE Flex
- 如果您对在 GAE Standard 上使用 Ghost 很执着,请像在示例中那样使用 Express,但将其设置为 Ghost 的适配器。有一个单一的 Express 请求处理程序,将请求提供给 Ghost 并将来自 Ghost 的响应传回(事实上,这个功能请求听起来像我试图描述的内容https://github.com/TryGhost/Ghost/issues/827)
推荐阅读
- ios - Swift iOS - 如果发现错误,请尽早跳出状态
- java - 分页库最初返回空列表
- ios - 在 Swift 中以编程方式从主 TabBarController 转到嵌套的 ViewController
- algorithm - 如何将无向图转换为每个节点最多有 K 个父节点的有向图?
- python - 输入键 Python Tkinter
- html - 如何在同一行对齐文本框?
- spring-boot - Spring Boot actuator - 实现自定义指标
- javascript - 我应该将可选参数默认设置为 false 还是 true
- python-3.x - 使用递归进行洪水填充 - Python
- c# - 如何在不重新编码的情况下更改课程?