tornado 使用supervisor管理進程,使用nginx做負載平衡

來源:互聯網
上載者:User
tornado 使用supervisor管理進程,使用nginx做負載平衡

部署方式

採用nginx作為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;    }}

運行命令:

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

注意:

  • 啟動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]; 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

運行命令:

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/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 <= lines; i++) { $numbering.append($('
  • ').text(i)); }; $numbering.fadeIn(1700); }); });

    以上就介紹了tornado 使用supervisor管理進程,使用nginx做負載平衡,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.