简体   繁体   English

Google Cloud App Engine上的Nodejs应用未启动

[英]Nodejs app on Google Cloud App Engine not starting

Good day, 美好的一天,

my very basic Nodejs app is deployed on a Google Cloud App Engine instance is not starting. 我在Google Cloud App Engine实例上部署的非常基本的Node.js应用无法启动。 The app works locally, deployment with app deploy runs without error - and on the app instance the app runs successfully when started manually through Cloud shell (with >npm start ). 该应用程序在本地运行,通过app deploy不会出错-并且在该应用程序实例上,通过Cloud Shell手动启动(使用>npm start )后,该应用程序成功运行。 However, as soon as the Cloud Shell is closed my app is dead. 但是,一旦Cloud Shell关闭,我的应用程序就会死机。 What am I missing? 我想念什么? How do I start-up the app to run permanently? 如何启动应用程序使其永久运行?

The app consists of 该应用程序包括

  • bot4.js file, bot4.js文件,
  • npm dependencies npm依赖
  • app.yaml 的app.yaml
  • package.json 的package.json

app.yaml: app.yaml中:

runtime: nodejs8
handlers:
- url: /
  script: auto

package.json: 的package.json:

{
  "name": "blexplorer",
  "version": "1.0.0",
  "description": "",
  "main": "bot4.js",
  "scripts": {
    "start": "node bot4.js"
  },
  "author": "oystersauce",
  "license": "ISC",
  "dependencies": {
    "discord.js": "^11.4.2",
    "request": "^2.88.0"
  }
}

Again, the app is running fine when started through the Cloud Shell but no longer, as soon as the Cloud Shell is closed. 同样,通过Cloud Shell启动该应用程序后运行良好,但在关闭Cloud Shell后不再运行。 Also, it's a super simple discord-bot - hence there is no front-end whatsoever. 而且,它是一个超级简单的和谐机器人-因此根本没有前端。

EDIT: this is how I thought I started the app manually - but what I did here is starting the app within the cloud shell and not on the app instance: 编辑:这就是我以为我手动启动了应用程序的方式-但是我在这里所做的是在云外壳中而不是在应用程序实例上启动应用程序: 在此处输入图片说明

here is how I deploy the app: 这是我部署应用程序的方式: 在此处输入图片说明

From GAE perspective the cloud shell is simply a shell on a "local" development machine which just happens to be hosted in the cloud. 从GAE角度看,云外壳只是“本地”开发计算机上的外壳,而恰好托管在云中。 The instance running the cloud shell has no special relationship with GAE whatsoever. 运行云外壳的实例与GAE没有任何特殊关系。

What you're doing when running npm start is not actually starting the GAE instance, you're just starting a "local" execution of your service, just like when you'd be doing the same on your local machine. 运行npm start时所执行的操作实际上并不是在启动GAE实例,而是在启动服务的“本地”执行,就像在本地计算机上执行该操作一样。

With your configuration GAE should start your app automatically as soon a request for it is received. 使用您的配置,GAE应在收到请求后立即自动启动您的应用程序。 On an app with a frontend just clicking on the link you circled in the snapshot would get you on it. 在具有前端的应用程序中,只需单击您在快照中圈出的链接即可进入。 Since yours doesn't have a frontend it would probably be just started, but you'd have to rely on the dashboard info and/or your app's logs to confirm it is running. 由于您的前端没有前端,因此它可能刚刚启动,但是您必须依靠仪表板信息和/或应用程序的日志来确认其正在运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM