简体   繁体   English

在应用程序结构方面,Google App Engine应用程序中的默认服务/模块可以是非默认服务/模块的兄弟吗?

[英]Can a default service/module in a Google App Engine app be a sibling of a non-default one in terms of folder structure?

Update: modules are called services these days. 更新: modules现在被称为services

I would like to organize my project's modules into various subfolders, where each subfolder contains code pertaining to each module. 我想将项目的模块组织到各种子文件夹中,其中每个子文件夹包含与每个模块有关的代码。 In particular, I would like the folder containing the default module to be on the same level as other modules (ie they are all siblings). 特别是,我希望包含默认模块的文件夹与其他模块处于同一级别(即它们都是兄弟姐妹)。 I am following the diagram shown in the Modules documentation : 我按照模块文档中显示的图表:

图

However, what confuses me is the statement " Important: The app.yaml file must be located in your application's root directory ". 但是,令我困惑的是语句“ 重要:app.yaml文件必须位于应用程序的根目录中 ”。 Does this imply that the default module (and its app.yaml) must be in the project root directory, and therefore, be the parent of non-default modules? 这是否意味着默认模块(及其app.yaml)必须位于项目根目录中,因此是非默认模块的父项?

The modules can all be side by side. 这些模块都可以并排。 The <module>.yaml for each one can be inside the module dir. 每个<module>.yaml都可以在模块目录中。

The note about app.yaml file is misleading, it really applies just to single-module apps (many pieces of the documentation weren't updated for multi-module apps). 有关app.yaml文件的说明具有误导性,它实际上仅适用于单模块应用程序(许多文档未针对多模块应用程序进行更新)。

The default module's config file doesn't even have to be called app.yaml (or its dir called default ). default模块的配置文件甚至不必称为app.yaml (或其名为default dir)。 I'd keep the app-level config files ( cron.yaml , dispatch.yaml , queue.yaml and index.yaml ) at the top level, eventually symlinking them into the default (or other) module(s) as needed (some tools may complain otherwise). 我将应用级配置文件( cron.yamldispatch.yamlqueue.yamlindex.yamlindex.yaml在顶层,最终根据需要将它们符号化为默认(或其他)模块(一些工具可能会抱怨其他)。

Here's, for example, the structure I got to for one of my apps (the main dir contains the default module): 例如,我的一个应用程序的结构( main dir包含default模块):

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 related tools. 您只需要在调用相关工具时注意。 This is my cheat-sheet for that app, executed from the app's dir, some of it is also reflected in the pycharm project config (I'm running the development server inside pycharm): 这是我的应用程序的备忘单,从应用程序的目录执行,其中一些也反映在pycharm项目配置中(我在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 run the devserver: 要运行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 config files, as requested. 更新:根据要求添加了一些配置文件。

The dispatch.yaml file, taking care of the buildin module routing on both the appspot domain and my custom domain (everything else is automatically routed to the default module): dispatch.yaml文件,负责appspot域和我的自定义域上的buildin模块路由(其他所有内容都自动路由到默认模块):

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

The main.yaml file: main.yaml文件:

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"

The buildin.yaml 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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 删除Google应用引擎中的非默认模块 - Delete non-default Module in google app engine 如何在本地Google App Engine的非默认模块上访问Google Cloud Endpoints? - How to access Google Cloud Endpoints on non-default module of local Google App Engine? 扩展非默认版本的Google App Engine后端 - Scaling non-default version of Google App Engine Backend 在Google应用引擎中将任务添加到非默认队列 - adding task to non-default queue in google app engine 来自非默认模块的日志消息未显示在Google App Engine控制台中 - log messages from non-default module not showing up in google app engine console 具有非默认App Engine服务的Google Cloud Endpoints v2自定义域 - Google Cloud Endpoints v2 custom domain with non-default app engine service 使用 Google App Engine URL 模式到达非默认服务 - Using Google App Engine URL patterns to reach non-default service 我可以在非默认版本上使用Google App Engine接收传入邮件吗? - Can I receive incoming mail with Google App Engine on a non-default version? 将适用于Java的App Engine托管VM部署到非默认网络 - Deploy App Engine Managed VM for Java to non-default network 测试非默认的App Engine cron作业 - Testing non-default App Engine cron jobs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM