如何让Flask应用在服务器重启后运行?

2024-04-20 09:13:13 发布

您现在位置:Python中文网/ 问答频道 /正文

运行烧瓶应用程序的推荐方式是什么(例如通过Gunicorn?)以及如何在linux服务器(redhat)重启后自动进行配置和运行?

谢谢


Tags: 服务器应用程序烧瓶linux方式gunicornredhat
2条回答

我对RedHat了解不多,但它可以使用upstart来管理服务。在

因此,实现这一点的一种方法是:配置一个upstart作业,在引导时启动gunicorn进程。在

新启动作业文件(保存在/etc/init/mysuperwebapp.conf)如下所示:

description "My flask app served by gunicorn"                                                                                                                                 
start on runlevel [2345]
stop on runlevel [!2345]
chdir /p/ath/to/directory
exec /path/to/virtualenv/bin/gunicorn ...

要手动启动作业,请执行以下操作:

^{pr2}$

新启动文档:http://upstart.ubuntu.com/cookbook/

你看过supervisord了吗?它工作得相当好,如果重新启动的进程失败了,它会自动处理它们,并很好地处理错误日志

相关问题 更多 >