502 Bad Gateway при развертывании в GAE - PullRequest
0 голосов
/ 12 мая 2019

Я пытаюсь развернуть приложение nodejs в Google App Engine. Но я продолжаю получать 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/\1
  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

1 Ответ

0 голосов
/ 13 мая 2019

Я нашел свою ошибку. Это было в файле 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);
});
...