Python教程

python 如何部署服务器 不用flask启动

本文主要是介绍python 如何部署服务器 不用flask启动,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
  1. 导入库
from waitress import serve
  1. 启动的那块改成
serve(app, host="0.0.0.0", port=5001)
  1. 加入配置文件,放置在 /etc/supervisor/conf.d
    在这里插入图片描述
    在这里插入图片描述
[program:名字]
command=python3 启动文件----.py
user=root
autostart=true
autorestart=true
stdout_logfile=/usr/local/log/名字.log
stderr+logfile=/usr/local/log/名字_error.log
startsecs=10
startretries=3

重新启动服务

supervisorctl reload

执行,看一下服务都开启没

supervisorctl status

之后
服务重启关闭的话就用“supervisorctl stop 服务名” 和 “supervisorctl start 服务名”就行

“supervisorctl reload”是所有服务都重启了一下

这篇关于python 如何部署服务器 不用flask启动的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!