目前Caddy尚不支持uwsgi协议,因此需要安装Gunicorn来连接caddy和flask
pip install gunicorn
xxxxxxxxxx
mkdir test
vim test/test.py
xfrom flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "<h1 style='color:blue'>Hello There!</h1>"
if __name__ == "__main__":
app.run()
xxxxxxxxxx
vim test/wsgi.py
xxxxxxxxxx
from test import app
if __name__ == "__main__":
app.run()
xxxxxxxxxx
cd test
gunicorn -b "127.0.0.1:8000" wsgi:app
xxxxxxxxxx
vim /etc/caddy/Caddyfile
xxxxxxxxxx
test.wofost.com {
root /data/www/wofost.com/test
proxy / localhost:8000 {
transparent
}
}
xxxxxxxxxx
systemctl restart caddy.service
xxxxxxxxxx
yum install psmisc
pstree -ap|grep gunicorn
kill -HUP **** #restart
kill -9 **** #shutdown