GCP灵活环境:配置app.yaml以运行多个服务



我已经配置了两个服务,其中一个是默认的。但通过DNS查询https://gcpdev.company.com/one服务时,无法到达项目文件。例如:

如果我直接输入这个url, 500错误返回:

https://gcpdev.company.com/vendor-es2017.65ff9b5300ddf6707a5c.js

打开文件的正确方法是:

https://gcpdev.company.com/one/vendor-es2017.65ff9b5300ddf6707a5c.js

我的配置有问题吗?这些是default项目的文件:

dispatch.yaml

dispatch:
- url: "gcpdev.company.com/one/*"
service: default
- url: "gcpdev.company.com/two/*"
service: two-ui

app.yaml

runtime: nodejs12    
service: default
handlers:
- url: /one/(.*.(gif|png|jpg|less|json|woff|woff2|ttf|eot|scss|css|js|ico|svg)(|.map))$
static_files: dist/1
upload: dist/(.*)(|.map)
- url: /one/assets/data/appConfig.json
static_files: dist/assets/data/appConfig.json
upload: dist/assets/data/appConfig.json
- url: /one/(.*)
static_files: dist/index.html
upload: dist/index.html

对于two-ui项目,我有相同的dispatch.yaml和相似的app.yaml:

runtime: nodejs12        
service: two-ui

handlers:
- url: /two/(.*.(gif|png|jpg|less|json|woff|woff2|ttf|eot|scss|css|js|ico|svg)(|.map))$
static_files: dist/1
upload: dist/(.*)(|.map)

- url: /two/assets/data/appConfig.json
static_files: dist/assets/data/appConfig.json
upload: dist/assets/data/appConfig.json

- url: /two/(.*)
static_files: dist/index.html
upload: dist/index.html

您的调度规则提到您必须使用:

  • gcpdev.company.com/one/*
  • gcpdev.company.com/two/*

那么,对gcpdev.company.com/*的调用预计会失败。没有任何规则规定如何使用该模式。

:

打开文件的正确方法是:https://gcpdev.company.com/one/vendor-es2017.65ff9b5300ddf6707a5c.js

看一看例句是很有价值的:

例如:

dispatch:
# Default service serves the typical web resources and all static resources.
- url: "*/favicon.ico"
service: default**strong text**

如果您想提供没有/one/*/two/*模式的静态文件,您可能需要添加类似于上面提到的内容。

关于如何在服务上提供静态文件,检查Handlers元素是下一步。我的建议是首先关注dispatcher,然后再关注app.yaml中的处理程序。

最新更新