简体   繁体   English

部署多个package.json Google Cloud

[英]Deploying multiple package.json Google Cloud

I am trying to modify this build: https://github.com/ebidel/try-puppeteer 我正在尝试修改此版本: https//github.com/ebidel/try-puppeteer

I noticed that there are 2 package.json (and server.js) files. 我注意到有2个package.json (和server.js)文件。

  1. root ( https://github.com/ebidel/try-puppeteer/blob/master/package.json ) root( https://github.com/ebidel/try-puppeteer/blob/master/package.json

  2. backend ( https://github.com/ebidel/try-puppeteer/blob/master/backend/package.json ) 后端( https://github.com/ebidel/try-puppeteer/blob/master/backend/package.json

Why do they deploy the backend and front end separately, with 2 express servers? 为什么他们使用2台快速服务器分别部署后端和前端? Is this best practice? 这是最佳做法吗? Design overkill? 设计矫枉过正?

What is the purpose of having two server.js files (or two servers) in one project? 在一个项目中拥有两个server.js文件(或两个服务器)的目的是什么?

Does it have a hierarchy system I overlooked? 它是否有我忽略的层次结构系统?

Additionally, how do I deploy this project? 另外,我该如何部署这个项目? from root of from backend? 来自后端的根?

You should deploy both, root is the frontend. 你应该同时部署,root是前端。 From root : 从根:

npm run deploy-backend
npm run deploy-frontend

see package.json : https://github.com/ebidel/try-puppeteer/blob/master/package.json#L16 请参阅package.json: https//github.com/ebidel/try-puppeteer/blob/master/package.json#L16

Why do they deploy the backend and front end separately, with 2 express servers? 为什么他们使用2台快速服务器分别部署后端和前端? Is this best practice? 这是最佳做法吗? Design overkill? 设计矫枉过正?

Compare two yaml files for front and back -ends: 比较前端和后端的两个yaml文件:

https://github.com/ebidel/try-puppeteer/blob/master/app.yaml https://github.com/ebidel/try-puppeteer/blob/master/app.yaml

automatic_scaling:
 min_num_instances: 1
 max_num_instances: 1

And

https://github.com/ebidel/try-puppeteer/blob/master/backend/app.yaml https://github.com/ebidel/try-puppeteer/blob/master/backend/app.yaml

automatic_scaling:
 min_num_instances: 1
 max_num_instances: 5

Author expects enough work for his backend to warrant scaling. 作者希望他的后端有足够的工作来保证扩展。 In fact his frontend mostly serves static data, which doesn't consume anything at all and is too simple to fail. 实际上,他的前端主要提供静态数据,它根本不消耗任何东西,而且太简单而不能失败。

Decoupling your application would imply that if backend is overloaded or crashed then front end will not suffer any downtime. 解耦应用程序意味着如果后端过载或崩溃,那么前端不会遭受任何停机。

What is the purpose of having two server.js files (or two servers) in one project? 在一个项目中拥有两个server.js文件(或两个服务器)的目的是什么?

In this case those are two different applications with loose coupling: rather than connect on level of program they connect through network/Google Cloud App Engine. 在这种情况下,这是两个不同的松散耦合应用程序:而不是通过网络/ Google Cloud App Engine连接程序级别。 If you want to see it more clearly grep for ports 8080 and 8081 in the git repository. 如果你想更清楚地看到git存储库中端口8080和8081的grep。 Many times “try-puppeteer/backend” would be a separate git repository with the hierarchy preserved and then downloade. 很多时候“try-puppeteer / backend”将是一个单独的git存储库,其中保留了层次结构,然后是下载。

Does it have a hierarchy system I overlooked? 它是否有我忽略的层次结构系统?

Frontend acts in as load balancer. 前端作为负载均衡器。 Again look at ports 8081 and 8080 in the code. 再次查看代码中的端口8081和8080。

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

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