Proxy Server的入口是bin/swift-proxy-server文件
import sys
from swift.common.utils import parse_options
from swift.common.wsgi import run_wsgi
if __name__ == '__main__':
conf_file, options = parse_options()
sys.exit(run_wsgi(conf_file, 'proxy-server', **options))
run_wsgi()函数会启动Proxy Server去监听用户的HTTP请求,Paste Deploy会在这个WSGI Server创建时参与进来,基于/etc/swift/proxy-server.conf去加载WSGI Application。
在随后swift-proxy-server的运行过程中,Paste Deploy会将监听到的HTTP请求根据Paste配置文件准确路由到特定的WSGI Application。
[pipeline:main]
pipeline = catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk tempurl ratelimit tempauth container-quotas account-quotas slo dlo proxy-logging proxy-server
[app:proxy-server]
use = egg:swift#proxy
[filter:slo]
use = egg:swift#slo
在pipeline里除了最后一个proxy-server,其他app都是作为filter的角色。“egg:swift#proxy “表示使用swift包中的proxy模块,slo(Static Large Object)filter定义中的”egg:swift#slo “表示使用swift包中的slo模块,这些模块都在setup.cfg文件的”entry_points“中进行了配置,使用setuptools加载。
[entry_points]
paste.app_factory =
proxy = swift.proxy.server:app_factory
object = swift.obj.server:app_factory
mem_object = swift.obj.mem_server:app_factory
container = swift.container.server:app_factory
account = swift.account.server:app_factory
paste.filter_factory =
healthcheck = swift.common.middleware.healthcheck:filter_factory
crossdomain = swift.common.middleware.crossdomain:filter_factory
memcache = swift.common.middleware.memcache:filter_factory
ratelimit = swift.common.middleware.ratelimit:filter_factory
根据setup.cfg的配置,Paste Deploy最终将使用swift.proxy.server模块的app_factory()函数构建proxy-server这个WSGI app。