使用uwsgi作为本地开发服务器的paster命令
pasteuwsgi的Python项目详细描述
粘贴uwsgi
pasteuwsgi是一个简单的python粘贴(http://pythonpaste.org/)插件 它添加了一个命令,为使用uwsgi的应用程序提供服务 (http://projects.unbit.it/uwsgi/)集成http服务器。它可以监视python 文件并在文件更改时自动重新加载uwsgi。是本地的 易于测试uwsgi特定特性的开发。
安装
首先,要使用pasteuwsgi您需要安装uwsgi,包括sistem-wide或 在虚拟世界里。查看uwsgi文档了解如何安装uwsgi (http://projects.unbit.it/uwsgi/wiki/Install)。最简单的方法是安装 在virtualenv中使用uwsgi,使用pip:
# pip install uwsgi
然后,您可以通过pypi:
安装pasteuwsgi# pip install pasteuwsgi
或者,如果您想要上一个不稳定的版本,直接从bitbucket(再次使用pip):
# pip install -e hg+https://bitbucket.org/gbagnoli/pasteuwsgi#egg=pasteuwsgi
或者您可以克隆hg repo,然后安装:
# hg clone https://gbagnoli@bitbucket.org/gbagnoli/pasteuwsgi # pip install -e ./
用法
安装后,只需将此行添加到粘贴应用程序的setup.py中:
uwsgi = pasteuwsgi.serve:ServeCommand
在入口点的“[Paste.Paster_命令]”部分 争论。
即,对于Pylons-1.0应用程序:
entry_points=""" [paste.app_factory] main = aybu.cms.config.middleware:make_app [paste.app_install] main = pylons.util:PylonsInstaller [paste.paster_command] uwsgi = pasteuwsgi.serve:ServeCommand """,
添加新入口点后,您可能需要重新运行setuptools egg_info:
# cd my-project # python setup.py egg_info
选项
--address | Override the http server listening address. |
--port | Override the http server listening port. |
--reload | Setup a monitor (using pyinotify) to watch application code to reload on changes. It also monitors code installed in the virtualenv. |
--uwsgi | Pass additional options to uWSGI directly. Remember that you neeed to wrap uWSGI options with quotes. |
--plugins | Load uWSGI plugins (for uWSGI >= 0.9.7) |
示例
只需像使用Paster Serve那样运行即可:
paster uwsgi development.ini --reload
您可以使用-w开关添加uwsgi选项
# run with 2 workers with two threads each paster uwsgi development.ini --reload -w "-workers 2 --threads 2"
您甚至可以添加公共选项(例如线程或进程选项,或者 其他)到粘贴ini(上面的development.ini)中的[uwsgi]部分 示例):
[...] [uwsgi] threads = 2 workers = 2
这就像pasteuwsgi将–ini选项传递给具有相同ini it的uwsgi一样 使用。