九零不老心
发布于 2020-06-23 / 9 阅读 / 0 评论 / 0 点赞

supervisor细节

supervisor本身的资料我就不写了,只写几个细节问题
  1. supervisor不支持重启间等待,解决办法是将sleep等待内容,加入到command=/bin/startup.sh脚本中
  2. [program:projectname]的项目配置中,
    command=的启动指令必须是前台执行的命令,
    比如支持:/usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf -f,
    而不支持/usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf,
    注意:(-f参数是zabbix前端执行的意思),
    否则会报错:INFO exited: zabbix_agentd (exit status 0; not expected)
  3. 如果一些命令不支持前端执行,建议编写脚本实现前端执行
    #! /usr/bin/env bash
    set -eu
    
    pidfile="/var/run/your-daemon.pid"
    command=/usr/sbin/your-daemon
    
    # Proxy signals
    function kill_app(){
        kill $(cat $pidfile)
        exit 0 # exit okay
    }
    trap "kill_app" SIGINT SIGTERM
    
    # Launch daemon
    $command
    sleep 2
    
    # Loop while the pidfile and the process exist
    while [ -f $pidfile ] && kill -0 $(cat $pidfile) ; do
        sleep 0.5
    done
    exit 1000 # exit unexpected
  4. 提供一个范例: