Tornado using Supervisor management process, using Nginx for load balancing
Deployment method
Use Nginx as Load Banlancer
nginx的配置文件如下,放在/etc/nginx/sites-avaiable/下,然后再sites-enable下面创建软连接nginx有一个基础配置会include sites-enable下的文件。以下代码是被配置的http{}部分所includeupstream 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.confserver { 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; }}
To run the command:
sudo cp /home/opsys/running/detect-datacollect-server/deploy/detect-datacollect-server.conf /etc/nginx/sites-availablesudo ln -s /etc/nginx/sites-available/detect-datacollect-server.conf /etc/nginx/sites-enabled/detect-datacollect-server.confsudo service nginx start
Attention:
- When you start Nginx, note the default under the Sites-available directory, and do not include this file in nginx.conf.
- Different system corresponding to the directory is not the same, pay attention to
Using Supervisor for Management
安装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)02dprocess_name = %(program_name)s%(process_num)dautorestart=trueredirect_stderr=truestdout_logfile=/home/opsys/log/detect-data-stdout.logstdout_logfile_maxbytes=50MBstdout_logfile_backups=10stderr_logfile=/home/opsys/log/detect-data-stderr.logloglevel=infonumprocs = 4numprocs_start = 1
To run the command:
sudo cp /home/opsys/running/detect-datacollect-server/conf/supervisor/detect_data.conf /etc/supervisor/conf.d/sudo service supervisor start
Log directory
Depends on the configuration in the configuration file
- Program Log:/home/opsys/log/detect-data-stdout.log
- Log of Supervisor:/var/log/supervisor/supervisord.log
- Nginx log:/var/log/nginx/
Reference
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
The eighth chapter: https://github.com/alioth310/itt2zh/blob/master/ch8.html
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the tornado use of Supervisor management process, using Nginx to do load balancing, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.