<commit_before>Running and deploying
=====================

Since Tornado supplies its own HTTPServer, running and deploying it is
a little different from other Python web frameworks.  Instead of
configuring a WSGI container to find your application, you write a
``main()`` function that starts the server:

.. testcode::

    def main():
        app = make_app()
        app.listen(8888)
        IOLoop.current().start()

    if __name__ == '__main__':
        main()

.. testoutput::
   :hide:

Configure your operating system or process manager to run this program to
start the server. Please note that it may be necessary to increase the number 
of open files per process (to avoid "Too many open files"-Error). 
To raise this limit (setting it to 50000 for example)  you can use the ulimit command, 
modify /etc/security/limits.conf or setting ``minfds`` in your supervisord config.

Processes and ports
~~~~~~~~~~~~~~~~~~~

Due to the Python GIL (Global Interpreter Lock), it is necessary to run
multiple Python processes to take full advantage of multi-CPU machines.
Typically it is best to run one process per CPU.

Tornado includes a built-in multi-process mode to start several
processes at once.  This requires a slight alteration to the standard
main function:
<commit_msg>start guide-running<commit_after>运行和部署
=====================

因为Tornado内置了自己的HTTPServer, 运行和部署它与其他Python web框架不
太一样. 你需要写一个``main()``函数来启动服务, 而不是配置一个WSGI容器
来运行你的应用:

.. testcode::

    def main():
        app = make_app()
        app.listen(8888)
        IOLoop.current().start()

    if __name__ == '__main__':
        main()

.. testoutput::
   :hide:

配置你的操作系统或者进程管理器来运行这个程序以启动服务. 请注意, 增加每个
进程允许打开的最大文件句柄数是可能是必要的(为了避免"Too many open files"
的错误). 为了增加这个上限(例如设置为50000 ) 你可以使用ulimit命令, 
修改/etc/security/limits.conf 或者设置``minfds`` 在你的supervisord配置中.

Processes and ports
~~~~~~~~~~~~~~~~~~~

Due to the Python GIL (Global Interpreter Lock), it is necessary to run
multiple Python processes to take full advantage of multi-CPU machines.
Typically it is best to run one process per CPU.

Tornado includes a built-in multi-process mode to start several
processes at once.  This requires a slight alteration to the standard
main function:

{'fraction_non_alphanumeric': 0.10324616771866546, 'fraction_numerical': 0.008115419296663661, 'mean_word_length': 4.077803203661327, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1839586', 'n_tokens_mistral': 750, 'n_tokens_neox': 744, 'n_words': 267}