Can the default service / module in a Google App Engine application be a child of a non-standard folder structure?

Update: these days, modules are called services .

I would like to organize the modules of my project into different subfolders, where each subfolder contains code related to each module. In particular, I would like the folder containing the default module to be at the same level as the other modules (that is, all of them are siblings). I follow the diagram given in the module documentation :

diagram
(source: google.com )

However, the statement " Important: the app.yaml file must be in the root directory of your application " confuses me. Does this mean that the default module (and its app.yaml) should be in the root directory of the project and, therefore, not the default parent of the modules?

+8
source share
1 answer

All modules may be nearby. <module>.yaml for each of them can be inside the dir module.

The note about the app.yaml file is misleading, it really only applies to applications with one module (many parts of the documentation have not been updated for multi-module applications).

The default module configuration file should not even be called app.yaml (or its dir called default ). I would keep the configuration files at the application level ( cron.yaml , dispatch.yaml , queue.yaml and index.yaml ) at the top level, eventually linking them to the standard (or other) module (s) as needed (some tools may complain otherwise).

Here, for example, is the structure that I got for one of my applications (the main directory contains the default module):

 cron.yaml dispatch.yaml queue.yaml index.yaml main/cron.yaml -> ../cron.yaml main/index.yaml -> ../index.yaml main/main.yaml main/queue.yaml -> ../queue.yaml buildin/buildin.yaml buildin/index.yaml -> ../index.yaml buildin/queue.yaml-> ../queue.yaml 

You just need to pay attention when invoking the appropriate tools. This is my cheat sheet for this application, made from the application directory, some of them are also reflected in the configuration of the pycharm project (I am running the development server inside pycharm):

 appcfg.py update main/main.yaml buildin/buildin.yaml appcfg.py update_dispatch . appcfg.py update_indexes -A <app-name> main appcfg.py update_cron -A <app-name> . appcfg.py update_queues -A <app-name> . 

To start devserver:

 dev_appserver.py --host 0.0.0.0 --log_level=debug dispatch.yaml main/main.yaml buildin/buildin.yaml 

Update: added some of my configuration files as requested.

The dispatch.yaml file, taking care of the routing of the buildin module both in the appspot domain and in my user domain (all others are automatically redirected to the default module):

 application: <my_app> dispatch: - url: "buildin.my_domain.com/*" module: buildin - url: "buildin-dot-my_app.appspot.com/*" module: buildin - url: "*/buildin/*" module: buildin 

main.yaml file:

 application: my_app module: default version: 1 runtime: python27 api_version: 1 threadsafe: true handlers: - url: /(.*\.min\.css)$ static_files: stylesheets/\1 upload: stylesheets/.*\.min\.css$ secure: always - url: /(.*\.(ico|gif|png|jpg|svg))$ static_files: images/\1 upload: images/.*\.(ico|gif|png|jpg|svg)$ secure: always - url: .* script: main.app secure: always libraries: - name: webapp2 version: "2.5.2" - name: jinja2 version: "2.6" - name: pycrypto version: "2.6" 

File buildin.yaml :

 application: my_app module: buildin version: 1 runtime: python27 api_version: 1 threadsafe: true instance_class: B2 handlers: - url: /(.*\.min\.js)$ static_files: scripts/\1 upload: scripts/.*\.min\.js$ secure: always - url: /(.*\.min\.css)$ static_files: stylesheets/\1 upload: stylesheets/.*\.min\.css$ secure: always - url: /(.*\.(ico|gif|png|jpg|svg))$ static_files: images/\1 upload: images/.*\.(ico|gif|png|jpg|svg)$ secure: always - url: /buildin/cron* script: buildin.app login: admin - url: .* script: buildin.app secure: always libraries: - name: webapp2 version: "2.5.2" - name: jinja2 version: "2.6" - name: pycrypto version: "2.6" 
+17
source

All Articles