virtual+flask+gunicorn+supervisor 环境搭建 - V2EX
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 4851 次点击
    这是一个创建于 4698 天前的主题,其中的信息可能已经有所发展或是发生改变。
    看到这两天有两个同学问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     Solana     2696 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 32ms UTC 09:50 PVG 17:50 LAX 02:50 JFK 05:50
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86