tornado 使用supervisor管理进程,使用nginx做负载均衡
部署方式
采用nginx作为load banlancer
<code>nginx的配置文件如下,放在/etc/nginx/sites-avaiable/下,然后再sites-enable下面创建软连接
nginx有一个基础配置会include sites-enable下的文件。
以下代码是被配置的http{}部分所include
upstream detect_data_server {
server 127.0.0.1:8001;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
server 127.0.0.1:8004;
}
# Only retry if there was a communication error, not a timeout
# on the Tornado server (to avoid propagating "queries of death"
# to all frontends)
# proxy_next_upstream error; # this has been in nginx.conf
server {
listen 80;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://detect_data_server;
}
}
</code>运行命令:
<code>sudo cp /home/opsys/running/detect-datacollect-server/deploy/detect-datacollect-server.conf
/etc/nginx/sites-available
sudo ln -s /etc/nginx/sites-available/detect-datacollect-server.conf
/etc/nginx/sites-enabled/detect-datacollect-server.conf
sudo service nginx start
</code>注意:
使用supervisor进行管理
<code>安装supervisor最好用apt-get install 安装 放在/etc/supervisor/conf.d/目录下面。和nginx一样,supervisor也有一个基础配置 为/etc/supervisor/supervisord.conf,这个文件会去include conf.d中的文件 以下为配置: ; To take advantage of multiple cores, you'll need multiple processes. [group:gp_detect_data] programs=detect_data [program:detect_data] ; envir ; TEST for test environ. command=python /home/opsys/running/detect-datacollect-server/code/app.py --port=80%(process_num)02d process_name = %(program_name)s%(process_num)d autorestart=true redirect_stderr=true stdout_logfile=/home/opsys/log/detect-data-stdout.log stdout_logfile_maxbytes=50MB stdout_logfile_backups=10 stderr_logfile=/home/opsys/log/detect-data-stderr.log loglevel=info numprocs = 4 numprocs_start = 1 </code>
运行命令:
<code>sudo cp /home/opsys/running/detect-datacollect-server/conf/supervisor/detect_data.conf
/etc/supervisor/conf.d/
sudo service supervisor start
</code>log目录
具体的要看配置文件中的配置
参考
https://github.com/tornadoweb/tornado/wiki/Deployment
https://gist.github.com/didip/802561
http://gracece.com/2014/03/Tornado-supervisor+nginx/
http://www.tornadoweb.org/en/stable/guide/running.html
第八章:https://github.com/alioth310/itt2zh/blob/master/ch8.html
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });以上就介绍了tornado 使用supervisor管理进程,使用nginx做负载均衡,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号