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

supervisor 管理多个服务

  •  
  •   ingin · 2018-11-16 15:09:59 +08:00 · 4213 次点击
    这是一个创建于 1959 天前的主题,其中的信息可能已经有所发展或是发生改变。

    现在有两个服务,如果全部让 supervisor 去管理的话,配置文件该怎么写呢,直接写两个 program:x 吗?这样试过了,用 ps 可以找到这两个服务的进程,可是服务 2 是不可用的,服务 1 正常。

    19 条回复    2018-11-17 08:53:46 +08:00
    j0ck1e
        1
    j0ck1e  
       2018-11-16 15:32:50 +08:00
    服务 2 直接启动呢
    neoblackcap
        2
    neoblackcap  
       2018-11-16 15:35:56 +08:00
    根据我的实测经验,要不你配置写错,要不你代码写错,supervisor 是支持多个服务的,就是写两个[program:x]类似的 section
    ingin
        3
    ingin  
    OP
       2018-11-16 15:36:01 +08:00
    @j0ck1e #1 直接启动是可以的,服务 2 直接用 gunicorn 启动也可以,配置两个 program 后启动,刚开始服务 2 是可以用的,过一会就不行了,服务 1 始终正常
    ingin
        4
    ingin  
    OP
       2018-11-16 15:37:11 +08:00
    @neoblackcap #2 对的,他确实支持,我也刚不懂为啥了,要挂一起挂还能理解,挂一个留一个费解啊
    ingin
        5
    ingin  
    OP
       2018-11-16 15:39:21 +08:00
    @j0ck1e #1
    @neoblackcap #2
    我在两个 program 中都配置了 stopsignal=TERM 不影响吧
    j0ck1e
        6
    j0ck1e  
       2018-11-16 15:39:37 +08:00
    @ingin strace 调试试试
    j0ck1e
        7
    j0ck1e  
       2018-11-16 15:42:04 +08:00
    @ingin 不影响`TERM`是默认值
    ingin
        8
    ingin  
    OP
       2018-11-16 15:46:28 +08:00
    @j0ck1e #6 好的,我试下
    clino
        9
    clino  
       2018-11-16 15:50:55 +08:00
    用 supervisorctl status 看看状态,有启动问题可以去看相关的 log
    ingin
        10
    ingin  
    OP
       2018-11-16 15:59:31 +08:00
    @clino #9 状态 running,ps aux 能查到进程,在启动的大概 30 分内可以正常访问,之后就不能正常访问,可是进程还在
    cnbobolee
        11
    cnbobolee  
       2018-11-16 16:06:13 +08:00   ❤️ 1
    [include]
    files = /Users/lee/Programs/supvervisor/conf.d/*.conf
    一个服务一个文件,应该是配置文件写错了。
    neoblackcap
        12
    neoblackcap  
       2018-11-16 16:06:18 +08:00
    我同意 9 楼的说法,看日志,看看是为什么退出
    wispx
        13
    wispx  
       2018-11-16 16:08:40 +08:00
    supervisor 的配置文件里最底部,不是有个
    ;[include]
    ;files = relative/directory/*.ini
    前面分号去掉,改成:
    [include]
    files = /etc/supervisord.d/*.conf

    没有 /etc/supervisord.d/文件夹就自己新建一个
    然后在 /etc/supervisord.d/文件夹下任意新建服务配置文件
    clino
        14
    clino  
       2018-11-16 16:39:43 +08:00
    @ingin 那就去看应用的 log 有没有异常吧
    感觉是应用的问题和 supervisor 没关系
    ingin
        15
    ingin  
    OP
       2018-11-16 16:44:25 +08:00
    @clino #14 恩恩,我再去试下单独跑应用
    ingin
        16
    ingin  
    OP
       2018-11-16 16:47:24 +08:00
    @wispx #13 我是直接 echo_supervisord_conf 这个命令生成一份 myapp.conf,然后在这个配置文件中配了两个 program,启动:sudo supervisord -c myapp.conf, 然后这两个服务启动,但二三十分钟之后服务二不可用
    huanghe314
        17
    huanghe314  
       2018-11-16 20:10:27 +08:00 via Android
    supervisor 添加配置之后必须进行 reread 和 updte 操作,不然无效,好像重启也没用
    MonoLogueChi
        18
    MonoLogueChi  
       2018-11-17 02:12:00 +08:00 via Android
    看日志,进城还在,但是服务不能用,确定一下是不是你服务本身有问题
    wqxuan
        19
    wqxuan  
       2018-11-17 08:53:46 +08:00 via iPhone
    端口冲突?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3258 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 00:17 · PVG 08:17 · LAX 17:17 · JFK 20:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.