就文件夹结构而言,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?

查看:13
本文介绍了就文件夹结构而言,Google App Engine 应用程序中的默认服务/模块可以是非默认服务/模块的同级吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:modules 现在被称为 services.

我想将我的项目模块组织到各种子文件夹中,其中每个子文件夹都包含与每个模块相关的代码.特别是,我希望包含默认模块的文件夹与其他模块处于同一级别(即它们都是兄弟模块).我正在按照
(来源:google.com)

然而,让我感到困惑的是重要提示:app.yaml 文件必须位于应用程序的根目录中".这是否意味着默认模块(及其 app.yaml)必须在项目根目录中,因此是非默认模块的父级?

解决方案

所有模块都可以并排.每个.yaml都可以在模块目录中.

关于 app.yaml 文件的注释具有误导性,它实际上仅适用于单模块应用程序(许多文档没有针对多模块应用程序更新).

default 模块的配置文件甚至不必称为 app.yaml(或其目录称为 default).我会保留应用级配置文件(cron.yamldispatch.yamlqueue.yamlindex.yaml) 在顶层,最终根据需要将它们符号链接到默认(或其他)模块(某些工具可能会抱怨).

例如,这是我为我的一个应用程序获得的结构(main 目录包含 default 模块):

cron.yamldispatch.yaml队列.yaml索引.yamlmain/cron.yaml ->../cron.yamlmain/index.yaml ->../index.yaml主/主.yamlmain/queue.yaml ->../queue.yaml内置/内置.yaml内置/index.yaml ->../index.yamlbuildin/queue.yaml->../queue.yaml

调用相关工具时注意即可.这是我对该应用程序的备忘单,从应用程序的目录执行,其中一些还反映在 pycharm 项目配置中(我在 pycharm 中运行开发服务器):

appcfg.py 更新 main/main.yaml buildin/buildin.yamlappcfg.py update_dispatch .appcfg.py update_indexes -A 主要的appcfg.py update_cron -A .appcfg.py update_queues -A .

运行开发服务器:

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

更新:根据要求添加了我的一些配置文件.

dispatch.yaml 文件,负责处理 appspot 域和我的​​自定义域上的 buildin 模块路由(其他所有内容都会自动路由到默认模块):

应用程序:派遣:- 网址:buildin.my_domain.com/*"模块:内置- 网址:buildin-dot-my_app.appspot.com/*"模块:内置- url: "*/buildin/*"模块:内置

main.yaml 文件:

应用程序:my_app模块:默认版本:1运行时:python27api_version: 1线程安全:真处理程序:- 网址:/(.*.min.css)$static_files: 样式表/1上传:样式表/.*.min.css$安全:始终- 网址:/(.*.(ico|gif|png|jpg|svg))$静态文件:图像/1上传:图片/.*.(ico|gif|png|jpg|svg)$安全:始终- 网址:.*脚本:main.app安全:始终图书馆:- 名称:webapp2版本:2.5.2"- 名称:jinja2版本:2.6"- 名称:pycrypto版本:2.6"

buildin.yaml 文件:

应用程序:my_app模块:内置版本:1运行时:python27api_version: 1线程安全:真实例类:B2处理程序:- 网址:/(.*.min.js)$static_files: 脚本/1上传:scripts/.*.min.js$安全:始终- 网址:/(.*.min.css)$static_files: 样式表/1上传:样式表/.*.min.css$安全:始终- 网址:/(.*.(ico|gif|png|jpg|svg))$静态文件:图像/1上传:图片/.*.(ico|gif|png|jpg|svg)$安全:始终- 网址:/buildin/cron*脚本:buildin.app登录:管理员- 网址:.*脚本:buildin.app安全:始终图书馆:- 名称:webapp2版本:2.5.2"- 名称:jinja2版本:2.6"- 名称:pycrypto版本:2.6"

Update: modules are called services these days.

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 (i.e. they are all siblings). I am following the diagram shown in the Modules documentation:


(source: google.com)

However, what confuses me is the statement "Important: The app.yaml file must be located in your application's root directory". 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?

解决方案

The modules can all be side by side. The <module>.yaml for each one can be inside the module dir.

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

The default module's config file doesn't even have to be called app.yaml (or its dir called default). 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).

Here's, for example, the structure I got to for one of my apps (the main dir 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 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):

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:

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):

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:

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:

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"

这篇关于就文件夹结构而言,Google App Engine 应用程序中的默认服务/模块可以是非默认服务/模块的同级吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆