Nginx Tornado 和 Flask - 什么是好的启动/停止脚本和保持活动的方法
我已经设置了一个 Flask 应用程序,在由 nginx 支持的龙卷风服务器上运行。我编写了几个 bash 脚本来在部署新版本时重新加载服务器配置,但我对它们不满意。基本上我所拥有的是:
启动服务器(假设在项目根目录中)
# this starts the tornado-flask wrapper
python myapp.py --port=8000 # .. some more misc settings
# this starts nginx
nginx
停止它
pkill -f 'myapp.py'
nginx -s stop
重新启动
cd $APP_ROOT
./script/stop && ./script/start
很多时候这些工作并不顺利,我需要手动运行命令。另外,我正在寻找一种方法来验证服务是否处于活动状态,并在服务关闭时启动它。想法?谢谢。
I've set up a Flask application to run on a tornado server backed by nginx. I've written a couple of bash scripts to reload server configuration when a new version is deployed, but I am unhappy with them. Basically what I have is:
to start the server (assuming in project root)
# this starts the tornado-flask wrapper
python myapp.py --port=8000 # .. some more misc settings
# this starts nginx
nginx
to stop it
pkill -f 'myapp.py'
nginx -s stop
to restart
cd $APP_ROOT
./script/stop && ./script/start
Many times these don't work smoothly and I need to manually run the commands. Also, I'm looking for a way to verify the service is alive, and start it up if it's down. Thoughts? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Supervisor 就是您要找的人。
我用它来管理我的 Tornado 应用程序以及其他一些处理守护进程。
它将守护进程、处理日志记录、pid 文件...几乎您需要的一切。
Supervisor is what you are looking for.
It's what I use to manage my Tornado apps along with some other processing daemons.
It will daemonize, handle logging, pid files... Pretty much everything you need.