系统相关
首页 > 系统相关> > 部署flask(nginx,gunicron,supervisor)

部署flask(nginx,gunicron,supervisor)

作者:互联网

supervisor apt安装

配置文件

nginx(

[program:nginx]
command = /usr/sbin/nginx -g 'daemon off;'
startsecs=0
autostart=true
autorestart=true
stdout_logfile=/home/maj/flask/log/nginx_sup.log
redirect_stderr=true
priority=10
stopasgroup=true
killasgroup=true
stopsignal=INT
startsecs=10
startretries=10

)

gunicron(

[program:gunicorn]
command=/home/maj/flask/venv/bin/gunicorn -w4 -b0.0.0.0:8000 app:app ; supervisor启动命令
directory=/home/maj/flask ; 项目的文件夹路径
startsecs=0 ; 启动时间
stopwaitsecs=0 ; 终止等待时间
autostart=true ; 是否自动启动
autorestart=true
stopasgroup=true ; 是否自动重启
stdout_logfile=/home/maj/flask/log/gunicorn.log ; log 日志
stderr_logfile=/home/maj/flask/log/gunicorn.err
environment=MAIL_USERNAME="xxx",MAIL_PASSWORD="xxx",SECRET_KEY="xxx"

)

nginx配置文件:

server {
listen 80 default_server;
listen [::]:80 default_server;

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /home/maj/flask;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;

server_name _;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.

# try_files $uri $uri/templates/index.html$is_args$query_string;
proxy_pass http://0.0.0.0:8000/;
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


}


location /static {
# root /static;
alias /home/maj/flask/static;
}

标签:supervisor,gunicron,flask,server,nginx,proxy,home,maj
来源: https://www.cnblogs.com/do-ma/p/16095957.html