Python PasteDeploy笔记

最近一直在看OpenStack的源码,有很多项目都用了PasteDeploy, 所以今天做个笔记。刚看到一篇应该还不错的博文,讲的写一个简单的wsgi app,然后用paste deploy来部署,链接在这里



Paste Deployment is a system for finding and configuring WSGI applications and servers. For WSGI application consumers it provides a single, simple function (loadapp) for loading a WSGI application from a configuration file or a Python Egg. For WSGI application providers it only asks for a single, simple entry point to your application, so that application users don’t need to be exposed to the implementation details of your application.

使用PasteDeploy加载wsgi app

前面的博客已经写过一个简单的的wsgi app, 以下是paste deploy配置文件:

paste.app_factory = wsgi_app:app_factory

use = egg:PasteScript#wsgiutils
host =
port = 8080

这里使用了PasteScript来部署wsgi Server, 使用paste.app_factory协议来访问wsgi app。


sudo pip install PasteScript
sudo pip install wsgiutils

启动wsgi server:

sudo paster serve ./main-paste.ini

这样一个使用Paste Deploy加Paste Script部署的wsgi app就部署完成了。访问http://x.x.x.x:8080即可看到返回的网页。

Table of Contents