3种启动tornado的方式
r"""A non-blocking, single-threaded HTTP server.
翻译: 一个非阻塞的单线程HTTP服务器
A server is defined by a subclass of `.HTTPServerConnectionDelegate`,
or, for backwards compatibility, a callback that takes an
`.HTTPServerRequest` as an argument. The delegate is usually a
`tornado.web.Application`.
翻译:服务器由".HTTPServerConnectionDelegate"的子类定义,或者,对于向后兼容,一个回调".HTTPServerRequest"作为一个参数。委托通常是 "tornado.web.Application"。
`HTTPServer` supports keep-alive connections by default
(automatically for HTTP/1.1, or for HTTP/1.0 when the client
requests ``Connection: keep-alive``).
翻译:默认情况下,HTTPServer支持keep-alive连接(自动为HTTP/1.1,或HTTP/1.0,当客户端请求的连接:维生”)。
If ``xheaders`` is ``True``, we support the
``X-Real-Ip``/``X-Forwarded-For`` and
``X-Scheme``/``X-Forwarded-Proto`` headers, which override the
remote IP and URI scheme/protocol for all requests. These headers
are useful when running Tornado behind a reverse proxy or load
balancer. The ``protocol`` argument can also be set to ``https``
if Tornado is run behind an SSL-decoding proxy that does not set one of
the supported ``xheaders``.
翻译:
如果"xheader"是"True",我们支持``X-Real-Ip``/``X-Forwarded-For````X-Scheme``/``X-Forwarded-Proto``的头,它覆盖了
所有请求的远程IP和URI模式/协议。这些头当在反向代理或负载下运行Tornado时是有用的均衡器。"protocol协议"的参数也可以设置为"https"。
如果Tornado是在一个SSL-decoding的代理后面运行的,它不会设置一个支持的“xheaders””。
By default, when parsing the ``X-Forwarded-For`` header, Tornado will
select the last (i.e., the closest) address on the list of hosts as the
remote host IP address. To select the next server in the chain, a list of
trusted downstream hosts may be passed as the ``trusted_downstream``
argument. These hosts will be skipped when parsing the ``X-Forwarded-For``
header.
翻译:
默认情况下,当解析``X-Forwarded-For``的header时,Tornado将会
选择最后一个(例如最接近的)在主机列表上的地址
远程主机IP地址。要选择链中的下一个服务器,一个列表
受信任的下游主机可以作为``trusted_downstream``“托管”
论点。在解析``X-Forwarded-For``时,这些主机将被跳过头。
To make this server serve SSL traffic, send the ``ssl_options`` keyword
argument with an `ssl.SSLContext` object. For compatibility with older
versions of Python ``ssl_options`` may also be a dictionary of keyword
arguments for the `ssl.wrap_socket` method.::
翻译:
要使这个服务器服务于SSL流量,请发送“ssloptions”关键字
用“ssl”进行论证。SSLContext”对象。为了与旧版本的兼容性
Python“ssloptions”的版本也可能是关键字的字典
关于“ssl”的争论。wrap_socket”方法。
针对https的做法
ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_ctx.load_cert_chain(os.path.join(data_dir, "mydomain.crt"),
os.path.join(data_dir, "mydomain.key"))
HTTPServer(applicaton, ssl_options=ssl_ctx)
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
`HTTPServer` initialization follows one of three patterns (the
initialization methods are defined on `tornado.tcpserver.TCPServer`):
. `~tornado.tcpserver.TCPServer.listen`: simple single-process:: 单进程
server = HTTPServer(app)
server.listen()
IOLoop.current().start()
In many cases, `tornado.web.Application.listen` can be used to avoid
the need to explicitly create the `HTTPServer`.
. `~tornado.tcpserver.TCPServer.bind`/`~tornado.tcpserver.TCPServer.start`:
simple multi-process::
server = HTTPServer(app)
server.bind()
server.start() # Forks multiple sub-processes // Forks 多个单进程
IOLoop.current().start()
When using this interface, an `.IOLoop` must *not* be passed
to the `HTTPServer` constructor. `~.TCPServer.start` will always start
the server on the default singleton `.IOLoop`.
. `~tornado.tcpserver.TCPServer.add_sockets`: advanced multi-process:: # 高级的多进程, 这个好处就是同脚本启动多个不同端口服务, 2则不可以
sockets = tornado.netutil.bind_sockets()
tornado.process.fork_processes() #
server = HTTPServer(app)
server.add_sockets(sockets)
IOLoop.current().start()
The `~.TCPServer.add_sockets` interface is more complicated,
but it can be used with `tornado.process.fork_processes` to
give you more flexibility in when the fork happens.
`~.TCPServer.add_sockets` can also be used in single-process
servers if you want to create your listening sockets in some
way other than `tornado.netutil.bind_sockets`.
.. versionchanged:: 4.0
Added ``decompress_request``, ``chunk_size``, ``max_header_size``,
``idle_connection_timeout``, ``body_timeout``, ``max_body_size``
arguments. Added support for `.HTTPServerConnectionDelegate`
instances as ``request_callback``.
.. versionchanged:: 4.1
`.HTTPServerConnectionDelegate.start_request` is now called with
two arguments ``(server_conn, request_conn)`` (in accordance with the
documentation) instead of one ``(request_conn)``.
.. versionchanged:: 4.2
`HTTPServer` is now a subclass of `tornado.util.Configurable`.
.. versionchanged:: 4.5
Added the ``trusted_downstream`` argument.
"""
tornado https 该怎么写
翻译:
要使这个服务器服务于SSL流量,请发送“ssloptions”关键字
用“ssl”进行论证。SSLContext”对象。为了与旧版本的兼容性
Python“ssloptions”的版本也可能是关键字的字典
关于“ssl”的争论。wrap_socket”方法。 针对https的做法 ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_ctx.load_cert_chain(os.path.join(data_dir, "mydomain.crt"),
os.path.join(data_dir, "mydomain.key"))
HTTPServer(applicaton, ssl_options=ssl_ctx) 方法二、
zkey.cc/fullchain.pem", "keyfile":"/etc/letsencrypt/live/
zkey.cc/privkey.pem"}) 第一种启动方式
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop `HTTPServer` initialization follows one of three patterns (the
initialization methods are defined on `tornado.tcpserver.TCPServer`): 1. `~tornado.tcpserver.TCPServer.listen`: simple single-process:: 单进程 server = HTTPServer(app)
server.listen(8888)
IOLoop.current().start() In many cases, `tornado.web.Application.listen` can be used to avoid
the need to explicitly create the `HTTPServer`.
第二种启动方式
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
2. `~tornado.tcpserver.TCPServer.bind`/`~tornado.tcpserver.TCPServer.start`:
simple multi-process:: server = HTTPServer(app)
server.bind(8888)
server.start(0) # Forks multiple sub-processes // Forks 多个单进程
IOLoop.current().start() When using this interface, an `.IOLoop` must *not* be passed
to the `HTTPServer` constructor. `~.TCPServer.start` will always start
the server on the default singleton `.IOLoop`.
第三种启动方式
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
3. `~tornado.tcpserver.TCPServer.add_sockets`: advanced multi-process:: # 高级的多进程, 这个好处就是同脚本启动多个不同端口服务, 2则不可以 sockets = tornado.netutil.bind_sockets(8888)
tornado.process.fork_processes(0) #
server = HTTPServer(app)
server.add_sockets(sockets)
IOLoop.current().start() The `~.TCPServer.add_sockets` interface is more complicated,
but it can be used with `tornado.process.fork_processes` to
give you more flexibility in when the fork happens.
`~.TCPServer.add_sockets` can also be used in single-process
servers if you want to create your listening sockets in some
way other than `tornado.netutil.bind_sockets`.
3种启动tornado的方式的更多相关文章
- Tornado—三种启动tornado的方式
第一种启动方式:单进程 import tornado.web # web服务 import tornado.ioloop # I/O 时间循环 class Mainhandler(tornado.we ...
- Oracle命令(二):Oracle数据库几种启动和关闭方式
一.Oracle数据库几种启动方式 1.startup nomount 非安装启动,这种方式下启动可执行:重建控制文件.重建数据库,读取init.ora文件,启动instance,即启动SGA和后台进 ...
- Activity的几种启动跳转方式
一.显示调用方法 •Intent intent=new Intent(this,OtherActivity.class); //方法1 •Intent intent2=new Intent(); • ...
- 第一章 Mybtais的两种启动方式
Mybatis的两种启动方式如下: 1.xml实现: xml的实现方式中,主要是通过手动创建SqlSession,然后调用session.selectOne()方法实现来实现. 首先是创建Config ...
- mysql 4种启动方式
mysql 4种启动方式 都是去调用mysqld文件 1. mysqld 启动 进入mysqld文件所在目录(/../libexec/mysqld) ./mysqld --defaults-file= ...
- Hadoop 学习笔记 (八) hadoop2.2.0 测试环境部署 及两种启动方式
1基本流程步骤1:准备硬件(linux操作系统)步骤2:准备软件安装包,并安装基础软件(主要是JDK)步骤3:修改配置文件步骤4:分发hadoop步骤5:启动服务步骤6:验证是否启动成功!2硬件配置要 ...
- ARM的两种启动方式 (NAND FLASH. NOR FLASH)
为什么会有两种启动方式? 这就是有两种FLASH 的不同特点决定的. NAND FLASH 容量大,存储的单位比特数据的成本要低很多,但是要按照特定的时序对NAND FLASH 进行读写,因此CP ...
- Android Activity 的四种启动模式 lunchMode 和 Intent.setFlags();singleTask的两种启动方式。
原文:Android Activity 的四种启动模式 lunchMode 和 Intent.setFlags();singleTask的两种启动方式. Android Activity 的四种启动模 ...
- tomcat三种启动不同的启动方式
Linux下tomcat服务的启动.关闭与错误跟踪,通常通过以下几种方式启动关闭tomcat服务: 切换到tomcat主目录下的bin目录 1. 启动tomcat服务 方式一:直接启动 ./start ...
随机推荐
- HTML杂记
1.URL uniform resource locator 遵循格式: scheme://host.domain:port/path/filename scheme - 定义因特网服务的类型.最常 ...
- [Windows Azure] Building the web role for the Windows Azure Email Service application - 3 of 5
Building the web role for the Windows Azure Email Service application - 3 of 5. This is the third tu ...
- u3d中刚体与碰撞体的理解以及is Trigger属性的意义
刚体:个人理解就是具有物理属性(如:质量),接受物理作用(如:重力)的组件. 碰撞体:个人理解就是计算碰撞后的物理量(如:弹力). 刚体与碰撞体的关系:个人理解判断碰撞体就是需要计算力,如果碰撞的物体 ...
- 【Socket】linux下http服务器开发
1.mystery引入 1)超文本传输协议(HTTP)是一种应用于分布式.合作式.多媒体信息系统的应用层协议 2)工作原理 1)客户端一台客户机与服务器建立连接后,会发送一个请求给服务器,请求方式的格 ...
- 【Socket】linux高性能网络服务程序
1.mystery引入 1)高性能的网络服务程序分为单线程重复式网络服务.多进程网络服务 .多线程网络服务.线程池网络服务和IO多路复用网络服务等 2)单线程重复式是最基本的一种TCP服务模式,其实现 ...
- 【Socket】linux网络多路复用IO技术
1.mystery引入 1)Select是一种多路复用IO输入输出模式,在linux的输入输出编程中通过select的轮询机制,发现可用/可读或可写的接口. 2)低级socket程 ...
- QQ通信原理及QQ是怎么穿透内网进行通信的?
http://blog.csdn.net/frank_good/article/details/51160027 ******************************************* ...
- django中将model转换为dict的方法
django中将model转换为dict的方法 from django.forms.models import model_to_dict from user.model import userpro ...
- decode和encode
作者:于洋链接:https://www.zhihu.com/question/23374078/answer/69732605来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出 ...
- 再论FreeRTOS中的configTOTAL_HEAP_SIZE
关于任务栈和系统栈的基础知识,可以参考之前的随笔.(点击这里) 这里再次说明:#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 17 * 1024 ) ) 这个 ...