首页 > 其他 > 详细

flask部署实践

时间:2016-07-12 13:44:07      阅读:144      评论:0      收藏:0      [点我收藏+]

用flask mongodb开发了内部工具,部署在了ucloud centos上

已经稳定的跑了半个月了

现在记录一下部署的过程

使用gunicorn怪兽作为wsgi 指定gevent 协程作为其worker-class

使用supervisor来管理和自动重启,使用nginx来反向代理

 

#supervisor

###supervisor

#web ui
[inet_http_server]         ; inet (TCP) server disabled by default
port=*:9002      ; (ip_address:port specifier, *:port for all iface)
username=root007              ; (default is no username (open server))
password=toor@root007              ; (default is no password (open server))

#co.xxxx.com
[program:co]
command = gunicorn --worker-class=gevent -w5 -b0.0.0.0:3000 run:app
directory=/home/www/co.xxxx.com/
autostart=true
user=www
redirect_stderr=true
stdout_logfile=/home/www/datas/supervisorlog/co.log
stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=10     ; # of stdout logfile backups (default 10)

 

 

#nginx

#/usr/local/nginx/conf/vhost
server {
    listen 80;
    server_name co.xxxx.com;
    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Cookie $http_cookie;
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $http_host;
    }

    location ^~ /static/ {
        root /home/www/co.xxxx.com/;
        expires 30d;
    }
}

 

 

#启动过程

#supervisor
supervisord #supervosirctl #
supervisor> status co
#nginx
/usr/local/nginx/sbin/nginx -s reload

 

;)

flask部署实践

原文:http://www.cnblogs.com/shiv/p/5663056.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!