0

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

  • module-api for REST API
  • module-oli for backend static process ..

regarding to doc (https://cloud.google.com/appengine/docs/php/modules/ and https://cloud.google.com/appengine/docs/php/modules/routing) I've created 3 .yaml config files:

dispatch.yaml

application: ABC

dispatch:
- url: "*/oli/*"
  module: module-oli

- url: "*/"
  module: module-api

app.yaml

application: ABC
version: v1
module: module-api
runtime: php55
api_version: 1

handlers:
- url: /.*
  script: public/api.php

module-oli.yaml

application: ABC
version: v1
module: module-oli
runtime: php55
api_version: 1

manual_scaling:
  instances: 1

handlers:
  - url: /.*
    script: public/oli.php

I also tried many changes in URL handling, but the error I always get is "Duplicate module: module-api".

Can you help me please? Thank you in advance ..

Zeehad
  • 1,012
  • 1
  • 9
  • 11
  • Normally app.yaml would be for your default module. You might need to redeploy your default module and then deploy your two modules separately. That's what I would do! – Tom Feb 15 '16 at 08:16
  • thank you @Tom, even if do not specify module in app.yaml (leaving it as default) and in dispatch.yaml pointing default calls ("*/") to module: default .. it still says "duplicate module: default" .. I'm very lost with it, because I do not see anything wrong there .. thank you .. – Jan Kremlacek Feb 15 '16 at 18:18
  • You should also remove the "application" line form your dispatch.yaml – Tom Feb 15 '16 at 18:22
  • You should remove the "application" line from your dispatch.yaml then deploy using `appcfg.py -A update_dispatch .` – Tom Feb 15 '16 at 18:23
  • it still says the same :( .. thank you :) .. – Jan Kremlacek Feb 15 '16 at 18:25
  • I have just set this up and got it to work on a project of mine. I made some minor tweaks to the dispatch file – Tom Feb 15 '16 at 18:34
  • ```dispatch: - url: "*/oli/*" module: module-oli - url: "*/api/*" module: module-api ``` – Tom Feb 15 '16 at 18:34
  • Or you could remove the second dispatch rule and leave it to your default module. – Tom Feb 15 '16 at 18:37
  • Which command actually gives you the error? – Tom Feb 15 '16 at 18:37
  • thank you for helping me .. it looks like I'm really doing something wrong .. on a local machine I'm starting the project via GoogleAppEngineLauncher, and (as is written in doc) I've putted extra flags specifying dispatch.yaml, app.yaml, module-oli.yaml .. GoogleAppEngineLauncher says "duplicate module" .. if I update (even dispatch) the deploy version at gcloud, it looks like gcloud does not see the 2nd module .. sorry for taking your time @tom, there are not so many documentation. thank you so much for help .. – Jan Kremlacek Feb 15 '16 at 18:41
  • I do not think you can use dispatch.yaml in that way – Tom Feb 15 '16 at 18:42
  • Try without specifying dispatch.yaml – Tom Feb 15 '16 at 18:44
  • finally found the solution, will check out how it works with dispatch (should be according to this article https://cloud.google.com/appengine/docs/php/modules/routing) and post the solution .. thank you @Tom for help .. – Jan Kremlacek Feb 16 '16 at 07:05

1 Answers1

0

I have no idea why, but (on my computer) it does not work just from googleAppEngineLauncher.app (OSX 10.11.3, googleAppEngineLauncher version 1.9.32), but it works if I use command line tools:

dev_appserver.py app.yaml module-oli.yaml

and only if I do not use param --skip_sdk_update_check (does not matter value)

more about naming modules (and using default module or not) .. it all works even if I name default module with specific name (of course, it causes error when not all request are dispatched to the module).

more about dispatching to modules; it works (as it's documented here). of course, it does not work at local development environment, as every single module runs at a different port (than the dispatch does not work, and if there is a module with manual_scaling, the _ah/start can not be handled and as err500 it stops the start)

here are all setup files, and how to run it:

app.yaml

application: <APPLICATION-ID>
module: default
version: v1
runtime: php55
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: .*
  script: blablabla.php

module-oli.yaml

application: <APPLICATION-ID>
version: v1
module: module-oli
runtime: php55
api_version: 1
threadsafe: yes

instance_class: B1

manual_scaling:
  instances: 1

handlers:
  - url: /oli/.*
    script: blebleble-oli.php

dispatch.yaml

dispatch:
  - url: "*/oli/*"
    module: module-oli

  - url: "*/*"
    module: default

to run on local development environment: dev_appserver.py app.yaml module-oli.yaml .. (no automatic routing, instances are running on different ports)

one everything is deployed to gcloud and dispatching is updated (appcfg.py -A wellfedcat-1221 update_dispatch .), it works like this:

  • APPLICATION-ID.appspot.com/* : served by default module ..
  • APPLICATION-ID.appspot.com/oli/* : served by module-oli ..

the dispatching is necessary when you want to use our own domain to map to gcloud ..

thank you @Tom for help!