1

我的情况是,我有一个应用引擎服务 ( service-a) 需要处理特定路径 ( domain.com/some/particular/path),而我在同一个域 ( service-b) 上有另一个应用引擎服务 (),需要处理到该域 ( domain.com/*) 的所有其他流量。

我已经尝试dispatch.yaml按如下方式构建我的,但是无论我做什么,domain.com/some/particular/path最终都会得到处理,service-b而不是service-a. 换句话说,所有路径都被路由到service-b.

dispatch:
  - url: "domain.com/some/particular/path"
    service: service-a
  - url: "domain.com/*"
    service: service-b

我该如何处理这种情况?

4

1 回答 1

2

This seems to be more about your code than the dispatch.yaml file that is roting to service-b. For example, I deployed two services, service 1:

from flask import Flask

app = Flask(__name__)


@app.route('/')
def hello():
    return 'Service 1'


if __name__ == '__main__':
    app.run(host='127.0.0.1', port=8080, debug=True)

And service 2:

from flask import Flask

app = Flask(__name__)


@app.route('/')
def hello():
    return 'Service 2'


if __name__ == '__main__':
    app.run(host='127.0.0.1', port=8080, debug=True)

With the following dispatch.yaml:

dispatch:
  - url: "domain.com/app2/"
    service: app2
  - url: "domain.com/*"
    service: default

If I try to access to domain.com/app2/ it shows NOT FOUND error message. If I change the routing in service 2 from @app.route('/') to @app.route('/app2') it works like a charm.

I think that your dispatch.yaml redirects to your service-a but the code inside that service redirects to domain.com.

BTW, if inside your services all your .yaml files are named app.yaml GAE for an unknown reason redirect to the default service so it's better to name every .yaml as the service it handles.

于 2019-12-31T18:04:50.347 回答