在确保我的 RESTful API 在本地正常工作后,我按照以下指南中的说明进行部署: https://cloud.google.com/nodejs/getting-started/hello-world
...我相信我做对了。之后我得到了以下屏幕 gcloud 应用部署 运行完毕。
可悲的是,https://_project-id.appspot.com (或在命令行上使用 gcloud app 浏览)不断导致 502 服务器错误:
错误:服务器错误
服务器遇到临时错误,无法完成您的请求。 请在 30 秒后重试。
(是的,我又尝试了多次)
================================================== ========= 编辑: 当我检查部署管理器时,它说: 您还没有任何部署。
这里会出现什么问题?
app.yaml
# Copyright 2015-2016, Google, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# [START runtime]
runtime: nodejs
env: flex
# [END runtime]
package.json
{
"name": "plusfriend",
"version": "1.0.0",
"description": "Jjalkey Kakao Plus Friend/YellowID RESTful API",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"body-parser": "*",
"express": "4.14.1",
"mongoose": "4.8.1",
"gcloud": "^0.37.0"
},
"author": "Edward Joon-Hyuk Chang",
"license": "ISC"
}
server.js 的最后一部分
// Listen
app.listen(80);
有什么想法我应该做什么吗? 预先非常感谢您。
最佳答案
对于这个问题,我只是重组了一切。您可以在此处查看文件:https://github.com/edwardjhchang/Jjalkey-Kakao-Talk-Plus-Friend-Auto-Reply-API
最重要的是,您必须创建 var http = require('http');
(我最初没有意识到)。检查我的存储库以获取更多详细信息:D
关于node.js - Google Cloud Platform 应用部署导致 502 服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42122057/