推荐学习书目
› 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
notedit
V2EX  ›  Python

virtual+flask+gunicorn+supervisor 环境搭建

  •  
  •   notedit ·
    notedit · Dec 1, 2012 · 5481 views
    This topic created in 5047 days ago, the information mentioned may be changed or developed.
    看到这两天有两个同学问flask的部署问题, 于是把自己用来开发的flask应用的基础代码拿出来,并写了一点配置过程.

    见github https://github.com/notedit/flask-base
    9 replies  •  1970-01-01 08:00:00 +08:00
    humiaozuzu
        1
    humiaozuzu  
       Dec 1, 2012
    thx :-)

    另外一个问题,如果用没 root 权限的用户部署的话,他也没有写入到 /var/log/ 的权限了?如何解决这个问题?
    notedit
        2
    notedit  
    OP
       Dec 1, 2012
    @humiaozuzu 应该是 那就把相应的log目录放到该用户的home目录下或者其他有写权限的地方
    humiaozuzu
        3
    humiaozuzu  
       Dec 1, 2012
    新问题一个,我用fabric管理的时候远程登陆用哪个呢? 是wwwdata用户还是自己的账户? 如果用wwwdata我在更新完服务器文件后想要重启app没有权限,用自己的用户感觉不安全。
    notedit
        4
    notedit  
    OP
       Dec 1, 2012
    @humiaozuzu 你也可以为www-data 用户设置一个home目录啊 而且supervisor是可以设置某个进程只允许某个用户控制的 你看一下supervisor的文档
    humiaozuzu
        5
    humiaozuzu  
       Dec 1, 2012
    @notedit 可以 supervisord 本身就是root权限运行的,我要执行 supervisorctl 也需要root才能连到socket上进行通信。

    我试过 chmod u+x 给 supervisorctl,但是因为supervisorctl本身是python脚本,所以会失败
    liuxurong
        6
    liuxurong  
       Dec 1, 2012
    感谢。
    notedit
        7
    notedit  
    OP
       Dec 1, 2012
    @humiaozuzu 不是这样的

    [unix_http_server]
    file=/tmp/supervisord.sock
    chmod=0755
    chown=wwwuser:wwwuser

    看我给的例子 supervisorctl 和 supervisord 是通过这个[unix_http_server] 中的/tmp/supervisord.sock 你可以设置它的权限
    humiaozuzu
        8
    humiaozuzu  
       Dec 1, 2012
    @notedit 项目已经部署好了,非常感谢!

    supervisorctl 看了很久没发现让app重新读取配置文件的功能。 是不是只能自己 kill -HUP 呢?
    notedit
        9
    notedit  
    OP
       Dec 1, 2012
    @humiaozuzu supervisorctl restart program_name 可以重启某个应用

    supervisord重新读取配置文件就要重启了

    可以看看开发gunicorn那帮人开发的新的工具 https://github.com/benoitc/gaffer 可以重新读取配置文件
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   814 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 21:29 · PVG 05:29 · LAX 14:29 · JFK 17:29
    ♥ Do have faith in what you're doing.