在 GAE 中部署时出现 502 Bad Gateway
502 Bad Gateway while deploying in GAE
我正在尝试在 Google App Engine 中部署我的 nodejs 应用程序。
但是当我 运行
时,我一直收到 502 Bad Gateway
$ gcloud app browse
这是我的文件结构
->project
|___node_modules
|___models
|___routes
|___index.js
|___app.yaml
|___package.json
|___package.lock.json
|___public
|___index.html
|___js
这是我的 app.yaml 文件
env: flex
runtime: nodejs
threadsafe: true
manual_scaling:
instances: 1
# Handle the main page by serving the index page.
handlers:
- url: /
static_files: public/index.html
upload: public/index.html
- url: /(.*)
static_files: public/
upload: public/(.*)
# Recommended file skipping declaration from the GAE tutorials
skip_files:
- ^(.*/)?app\.yaml
- ^(.*/)?app\.yml
- ^(.*/)?#.*#
- ^(.*/)?.*~
- ^(.*/)?.*\.py[co]
- ^(.*/)?.*/RCS/.*
- ^(.*/)?\..*
- ^(.*/)?tests$
- ^(.*/)?test$
- ^test/(.*/)?
- ^COPYING.LESSER
- ^README\..*
- \.gitignore
- ^\.git/.*
- \.*\.lint$
- ^fabfile\.py
- ^testrunner\.py
- ^grunt\.js
- ^node_modules/(.*/)?
注意:我运行宁在端口8080上并且包含"start":"node index.js"在package.json
我发现了我的错误。它在 index.js 文件中。
之前:
const port = process.env.PORT || 8080;
app.listen(port, "localhost",()=>{
console.log("Server running at port " + port);
});
我不得不将其替换为:
const port = process.env.PORT || 8080;
app.listen(port, ()=>{
console.log("Server running at port " + port);
});
我正在尝试在 Google App Engine 中部署我的 nodejs 应用程序。 但是当我 运行
时,我一直收到 502 Bad Gateway$ gcloud app browse
这是我的文件结构
->project
|___node_modules
|___models
|___routes
|___index.js
|___app.yaml
|___package.json
|___package.lock.json
|___public
|___index.html
|___js
这是我的 app.yaml 文件
env: flex
runtime: nodejs
threadsafe: true
manual_scaling:
instances: 1
# Handle the main page by serving the index page.
handlers:
- url: /
static_files: public/index.html
upload: public/index.html
- url: /(.*)
static_files: public/
upload: public/(.*)
# Recommended file skipping declaration from the GAE tutorials
skip_files:
- ^(.*/)?app\.yaml
- ^(.*/)?app\.yml
- ^(.*/)?#.*#
- ^(.*/)?.*~
- ^(.*/)?.*\.py[co]
- ^(.*/)?.*/RCS/.*
- ^(.*/)?\..*
- ^(.*/)?tests$
- ^(.*/)?test$
- ^test/(.*/)?
- ^COPYING.LESSER
- ^README\..*
- \.gitignore
- ^\.git/.*
- \.*\.lint$
- ^fabfile\.py
- ^testrunner\.py
- ^grunt\.js
- ^node_modules/(.*/)?
注意:我运行宁在端口8080上并且包含"start":"node index.js"在package.json
我发现了我的错误。它在 index.js 文件中。 之前:
const port = process.env.PORT || 8080;
app.listen(port, "localhost",()=>{
console.log("Server running at port " + port);
});
我不得不将其替换为:
const port = process.env.PORT || 8080;
app.listen(port, ()=>{
console.log("Server running at port " + port);
});