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
notedit
V2EX  ›  Python

virtual+flask+gunicorn+supervisor 环境搭建

  •  
  •   notedit ·
    notedit · 2012-12-01 02:28:52 +08:00 · 4404 次点击
    这是一个创建于 4162 天前的主题,其中的信息可能已经有所发展或是发生改变。
    看到这两天有两个同学问flask的部署问题, 于是把自己用来开发的flask应用的基础代码拿出来,并写了一点配置过程.

    见github https://github.com/notedit/flask-base
    9 条回复    1970-01-01 08:00:00 +08:00
    humiaozuzu
        1
    humiaozuzu  
       2012-12-01 03:02:40 +08:00
    thx :-)

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

    我试过 chmod u+x 给 supervisorctl,但是因为supervisorctl本身是python脚本,所以会失败
    liuxurong
        6
    liuxurong  
       2012-12-01 15:13:26 +08:00
    感谢。
    notedit
        7
    notedit  
    OP
       2012-12-01 15:55:49 +08:00
    @humiaozuzu 不是这样的

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

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

    supervisorctl 看了很久没发现让app重新读取配置文件的功能。 是不是只能自己 kill -HUP 呢?
    notedit
        9
    notedit  
    OP
       2012-12-01 20:30:11 +08:00
    @humiaozuzu supervisorctl restart program_name 可以重启某个应用

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

    可以看看开发gunicorn那帮人开发的新的工具 https://github.com/benoitc/gaffer 可以重新读取配置文件
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2031 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 00:01 · PVG 08:01 · LAX 17:01 · JFK 20:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.