WSGI
,uwsgi
和uWSGI
WSGI
:全称是Web Server Gateway Interface
,是一种规范,只适用于Python
语言。要实现WSGI
协议,必须同时实现web server
和web application
,当前运行在WSGI
协议之上的web框架有Bottle
, Flask
, Django
。uwsgi
:与WSGI
一样是一种通信协议,是uWSGI
服务器的独占协议,用于定义传输信息的类型(type of information
),每一个uwsgi packet
前4byte
为传输信息类型的描述,与WSGI
协议是两种东西,据说该协议是fcgi
协议的10
倍快。uWSGI
:是一个web
服务器,实现了WSGI
协议、uwsgi
协议、http
协议等。
入口
入口函数在manage.py
中,从execute_from_command_line(sys.argv)
开始,这时候会传入[manage.py文件在的位置,command(runserver), 端口号]
:
def execute_from_command_line(argv=None):
"""
A simple method that runs a ManagementUtility.
"""
# 使用argv进行实例化
utility = ManagementUtility(argv)
utility.execute()
接下来调用execute()
方法,根据注释,这个方法根据subcommand
解析出需要的操作:
def execute(self):
"""
Given the command-line arguments, this figures out which subcommand is
being run, creates a parser appropriate to that command, and runs it.
"""
if settings.configured:
# Start the auto-reloading dev server even if the code is broken.
# The hardcoded condition is a code smell but we can't rely on a
# flag on the command class because we haven't located it yet.
if subcommand == 'runserver' and '--noreload' not in self.argv: