tornado 使用supervisor管理进程,使用nginx做负载均衡
2016-01-26 21:20
651 查看
tornado 使用supervisor管理进程,使用nginx做负载均衡
部署方式
采用nginx作为load banlancer
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; } }
运行命令:
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
注意:
启动nginx时要注意sites-available目录下面的default,在nginx.conf中不要include了这个文件
不同的系统对应的目录不一样,要注意
使用supervisor进行管理
安装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] ; environment=MODE="TEST" ; 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
运行命令:
sudo cp /home/opsys/running/detect-datacollect-server/conf/supervisor/detect_data.conf /etc/supervisor/conf.d/ sudo service supervisor start
log目录
具体的要看配置文件中的配置程序log:/home/opsys/log/detect-data-stdout.log
supervisor的log: /var/log/supervisor/supervisord.log
nginx log:/var/log/nginx/
参考
https://github.com/tornadoweb/tornado/wiki/Deploymenthttps://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
相关文章推荐
- apache和nginx的区别
- Nginx负载均衡
- Nginx使用ngx_zeromq模块返回502错误的解决方法
- WordPress程序伪静态规则(Nginx/Apache)及二级目录规则
- Nginx+Lua开发入门
- nginx高可用负载均衡配置
- Nginx安装 与使用 转载
- nginx安装与使用
- zabbix管理七之监控nginx性能
- DJANGO技巧两则:模拟MKDIR -P及配合NGINX上传大文件不使超时
- Nginx配置文件详细说明
- flume nginx 日志处理异常 JsonParseException: Unexpected character ('(' (code 40)): expected a valid value
- nginx 配置其他路径
- nginx connection failed due to Permission denied on CentOS7
- nginx启动、重启、关闭
- 最佳Nginx日志分析工具Goaccess
- nginx自动切割访问日志
- Nginx + Apache 公用 80 端口的配置方案。
- nginx日志自动按天分隔
- 主备切换,双机热备,负载均衡,nginx