Kev*_*Lee 8 google-app-engine module
更新:这些天modules被称为services.
我想将项目的模块组织到各种子文件夹中,其中每个子文件夹包含与每个模块有关的代码.特别是,我希望包含默认模块的文件夹与其他模块处于同一级别(即它们都是兄弟姐妹).我按照模块文档中显示的图表:
但是,令我困惑的是语句" 重要:app.yaml文件必须位于应用程序的根目录中 ".这是否意味着默认模块(及其app.yaml)必须位于项目根目录中,因此是非默认模块的父项?
Dan*_*scu 17
这些模块都可以并排.在<module>.yaml为每一个可以是模块DIR内部.
关于app.yaml文件的说明具有误导性,它实际上仅适用于单模块应用程序(许多文档未针对多模块应用程序进行更新).
该default模块的配置文件中甚至没有被调用app.yaml(或称为其目录default).我会保持应用程序级的配置文件(cron.yaml,dispatch.yaml,queue.yaml和index.yaml)在顶层,最终符号链接它们到默认(或其他)模块(S)根据需要(有些工具可能另有抱怨).
例如,这是我的一个应用程序所需的结构(maindir包含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
Run Code Online (Sandbox Code Playgroud)
您只需要在调用相关工具时注意.这是我的应用程序的备忘单,从应用程序的目录执行,其中一些也反映在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> .
Run Code Online (Sandbox Code Playgroud)
要运行devserver:
dev_appserver.py --host 0.0.0.0 --log_level=debug dispatch.yaml main/main.yaml buildin/buildin.yaml
Run Code Online (Sandbox Code Playgroud)
更新:根据要求添加了一些配置文件.
该dispatch.yaml文件buildin负责appspot域和我的自定义域上的模块路由(其他所有内容都自动路由到默认模块):
application: <my_app>
dispatch:
- url: "buildin.my_domain.com/*"
module: buildin
- url: "buildin-dot-my_app.appspot.com/*"
module: buildin
- url: "*/buildin/*"
module: buildin
Run Code Online (Sandbox Code Playgroud)
该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"
Run Code Online (Sandbox Code Playgroud)
该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"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2722 次 |
| 最近记录: |