当前位置: 代码迷 >> Web前端 >> 生产环境上部署Tornado+Supervisor
  详细解决方案

生产环境上部署Tornado+Supervisor

热度:350   发布时间:2012-12-25 16:18:28.0
生产环境下部署Tornado+Supervisor
1、安装supervisor
easy_install supervisor

2、配置supervisor
echo_supervisord_conf > /etc/supervisord.conf
vim /etc/supervisord.conf
-------------------------------------------------------
[program:tornado_app]
command=python tornado_app.py 80%(process_num)02d
process_name=%(program_name)s_(process_num)02d
umask=022
startsecs=0
stopwaitsecs=0
redirect_stderr=true
stdout_logfile=/tmp/codoon.log
numprocs=4
numprocs_start=1
--------------------
3、重启supervisor
supervisord
supervisorctl reload
查看supervisord和tornado的运行情况:
ps aux

4、配置nignx
--------------------
upstream frontends {      
  server 127.0.0.1:8001;      
  server 127.0.0.1:8002;      
  server 127.0.0.1:8003;      
  server 127.0.0.1:8004;
}
location / {                        
  proxy_pass_header Server;                        
  proxy_set_header Host $http_host;                        
  proxy_set_header X-Real-IP $remote_addr;                        
  proxy_set_header X-Scheme $scheme;                        
  proxy_pass http://frontends;                        
  proxy_next_upstream error;
}
--------------------
保存配置文件后执行  让nginx重启的指令 nginx -s reload
  相关解决方案