【问题标题】:How to add a delay to supervised process in supervisor - linux如何在主管中为受监督的进程添加延迟 - linux
【发布时间】:2014-12-08 04:15:42
【问题描述】:

我添加了一个使用 python 的 cassandra 库的瓶子服务器,但它退出并出现以下错误:
Bottle FATAL Exited too quickly (process log may have details)
日志显示:
File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 1765, in _reconnect_internal raise NoHostAvailable("Unable to connect to any servers", errors)

所以我尝试使用 supervisorctl start Bottle 手动运行它,然后它开始没有问题。结论= Bottle 服务启动太快(在所需的 cassandra 监督服务启动之前):需要延迟!

【问题讨论】:

    标签: python linux cassandra bottle supervisord


    【解决方案1】:

    这是我用的:

    [program:uwsgi]
    command=bash -c 'sleep 5 && uwsgi /etc/uwsgi.ini'
    

    【讨论】:

    • command=bash -c "sleep 5 && exec uwsgi /etc/uwsgi.ini": exec 会将 bash 替换为 uwsgi,双引号将确保包含的字符串将作为单个参数发送到 bash。
    • 当我这样做时,在我执行“supervisorctl stop”后进程会在后台继续运行
    • @kgreenek 是的,之前的评论将解决这个问题。除非你的实际程序坏了。
    【解决方案2】:

    sleep hack 不够满意,我创建了一个启动脚本并从那里启动了supervisorctl start processname

    [program:startup]
    command=/startup.sh
    startsecs = 0
    autostart = true
    autorestart = false
    startretries = 1
    priority=1
    
    [program:myapp]
    command=/home/website/venv/bin/gunicorn /home/website/myapp/app.py
    autostart=false
    autorestart=true
    process_name=myapp
    

    startup.sh

    #!/bin/bash
    sleep 5
    supervisorctrl start myapp
    

    这样,主管将触发一次启动脚本,这将在 5 秒后启动 myapp,请注意 myapp 上的 autostart=falseautorestart=true

    【讨论】:

      猜你喜欢
      • 2019-04-17
      • 2015-10-02
      • 2014-09-12
      • 2011-08-07
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 2019-12-14
      • 1970-01-01
      相关资源
      最近更新 更多