apprtc demo的app.yaml分析

apprtc的src目錄下,有幾個文件夾,其中有app_enginee、collider、third_party和web_app。

其中collider是信令服務器相關的code。之後在分析。
third_party裏面是一些庫之類的東西。在其readme.txt中有一段話:

These are libraries that are required but not provided by AppEngine.

third_party中還有一個requirements.txt,readme.txt涉及到這個文件的是

pip install --target=third_party --upgrade -r third_party/requirements.txt

pip是python包管理工具,類似npm之於nodejs的關係。通過requirements.txt來對python工程所需的包進行管理。
總的說來third_party是第三方包。

web_app是web_app所需的一些文件內容。在apprtc的編譯grunt build後移到out/app_enginee中。

轉到src/app_enginee/app.yaml分析,文件內容

application: apprtc
version: 9
runtime: python27
threadsafe: true
api_version: 1

handlers:
- url: /(.*\.html)
  static_files: html/\1
  upload: html/(.*\.html)

- url: /manifest.json
  static_files: html/manifest.json
  upload: html/manifest.json

- url: /robots.txt
  static_files: html/robot.txt
  upload: html/robots.txt

- url: /callstats
  static_dir: third_party/callstats

- url: /images
  static_dir: images

- url: /js
  static_dir: js

- url: /css
  static_dir: css

- url: /compute/.*
  script: apprtc.app
  login: admin

- url: /probe.*
  script: probers.app
  secure: always

- url: /.*
  script: apprtc.app
  secure: always

libraries:
- name: jinja2
  version: latest
- name: ssl
  version: latest
- name: pycrypto
  version: latest

env_variables:
  BYPASS_JOIN_CONFIRMATION: false
  # Only change these while developing, do not commit to source!
  # Use appcfg.py --env_variable=CALLSTATS_APP_ID:ID  \
  #               --env_variable=CALLSTATS_APP_SECRET:SECRET \
  #               --env_variable=ICE_SERVER_API_KEY:KEY \
  # in order to replace variables when deploying.
  CALLSTATS_APP_ID: none
  CALLSTATS_APP_SECRET: none
  ICE_SERVER_API_KEY: none

依據http://blog.csdn.net/day_day_up1991/article/details/52604671介紹,可知其中的application是app的ID,和GAE平臺上註冊之後見的網絡應用名相同。runtime和api_version表示依賴的運行環境和版本。
handlers表示不同url時,不同的處理方式。

 url: /manifest.json
  static_files: html/manifest.json
  upload: html/manifest.json

表示如果url後面爲/manifest.json,則對應的靜態文件爲html/mainfest.json。
如果是動態內容,則是腳本,比如

- url: /compute/.*
script: apprtc.app
login: admin

如果url爲/compute/任意內容,則用apprtc.app來處理。
不過從實際產生作用角度,是apprtc.py在處理。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章