How to properly setup modules for Google App Engine (PHP runtime)

508 Views Asked by At

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 ..

1

There are 1 best solutions below

0
On

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!