V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
humiaozuzu
V2EX  ›  Python

使用 gunicorn,supervisord 部署 flask app 的问题

  •  
  •   humiaozuzu ·
    humiaozuzu · 2012-11-30 23:45:51 +08:00 · 5041 次点击
    这是一个创建于 4171 天前的主题,其中的信息可能已经有所发展或是发生改变。
    因为部署的 flask 有些附属的监控,所以需要用 supervisord 管理,有如下的问题求解答:

    - app 放在 哪个目录下是 best practise 呢?
    - app 应该以 www-data 来运行吗?为何呢?
    - 用 www-data 身份运行的话就没权限在 /var/log/ 目录下存放日志了,这时日志放在哪个目录下好呢?
    - gunicorn 的配置可以指定 pid 文件和日志文件,supervisord 也是,这2者的pid是分开的吗? supervisord 重启 gunicorn 的时候是通过查看 gunicorn 的 pid 文件吗?gunicorn 的 日志文件此时应该怎么配置,是不是只需要配置 supervisord 的就可以了呢?
    4 条回复    1970-01-01 08:00:00 +08:00
    notedit
        1
    notedit  
       2012-12-01 00:19:56 +08:00   ❤️ 1
    根据自己的经验
    1, app放在与views放在同一级目录,在上一层再新建一个manage.py 导入app 我比较喜欢flask-script 这个插件
    2, 我一般会新建一个没有sudo权限的用户
    3, supervisord 有一套自己进行的管理机制, 不是通过gunicorn的pid文件. 日志文件只配置supervisord的日志就可以了, 它可以托管gunicorn的日志 但需要一些设置.
    humiaozuzu
        2
    humiaozuzu  
    OP
       2012-12-01 00:22:15 +08:00
    @notedit 万分感谢,能不能推荐些部署方面的 best practice 的文章呢? Google 了很久都是零零碎碎的知识。
    notedit
        3
    notedit  
       2012-12-01 00:38:24 +08:00
    这两天已经看到两个人问flask部署相关的了 我写一个吧 :)
    notedit
        4
    notedit  
       2012-12-01 02:30:34 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2040 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 390ms · UTC 01:29 · PVG 09:29 · LAX 18:29 · JFK 21:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.