简体   繁体   中英

Google App Engine - Could not find dispatch configuration

I want to create very standard setup for GAE (php runtime): 2 modules with specific URLs (routings):

  • module-api for REST API
  • module-app for web base application

I've created 4 .yaml config files:
app.yaml

application: ABC
version: 1
runtime: php55
api_version: 1
threadsafe: yes

automatic_scaling:
  max_idle_instances: 20

handlers:
- url: /.*
  script: api/web/index.php

dispatch.yaml

application: ABC

dispatch:
- url: "*/app/*"
  module: web-based

- url: "*/*"
  module: default

web_based.yaml

application: ABC
module: web-based
version: 1
runtime: php55
api_version: 1
threadsafe: yes

automatic_scaling:
  min_idle_instances: 2
  max_pending_latency: 1s

handlers:
- url: /(.*\.(gif|png|jpg|css|js|otf))
  static_files: /\1
  upload: /(.*\.(gif|png|jpg|js|css|otf))

api.yaml

application: ABC
module: default
version: 1
runtime: php55
api_version: 1
threadsafe: yes

manual_scaling:
  instances: 1

handlers:
- url: /(.*\.(gif|png|jpg|css|js|otf))
  static_files: web/\1
  upload: web/(.*\.(gif|png|jpg|js|css|otf))

- url: /assets/(.+)
  static_files: web/assets/\1
  upload: web/assets/(.+)

- url: /.*
  script: web/index.php  

Directory structure:

- api/api.yaml
- app/web_base.yaml
- app.yaml
- dispatch

When I try update_dispatch, I get dispatch configuration file is not found. Can someone help me?

In a multi-module app there is no app-level app.yaml anymore, there is only one .yaml file for each module and that's it.

So get rid of the top-level app.yaml (if needed merge its relevant content into the api.yaml file, which is the one for your default module). The 2 files collide and can confuse the update_dispatch operation. Then deploy the default module - often it needs to be deployed before app-level configs (like the dispatch.yaml file) and the other modules can be deployed.

Maybe peek at Can a default service/module in a Google App Engine app be a sibling of a non-default one in terms of folder structure? , it's for a python app but many things in there like app dir structure, app-level configs (dispatching for example) and deployment are applicable to php as well.

Side notes:

  • you're also missing a dynamic handler inside web_based.yaml .
  • you don't need a dispatch rule for the default module - that's where the requests with no routes are dispatched to anyways
  • personally I'd make the web app the default module and the REST one a non-default one - I wouldn't like all garbage coming in hitting the REST module by default...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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