flask部署實踐

用flask mongodb開發了內部工具,部署在了ucloud centos上nginx

已經穩定的跑了半個月了web

如今記錄一下部署的過程mongodb

使用gunicorn怪獸做爲wsgi 指定gevent 協程做爲其worker-classflask

使用supervisor來管理和自動重啓,使用nginx來反向代理centos

 

#supervisorcookie

###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)

 

 

#nginxapp

#/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

 

;)ui

相關文章
相關標籤/搜索