V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
love
V2EX  ›  Linux

关于 supervisor 的 autorestart 为 unexpected 时(默认值)的行为好奇怪,是我理解错了文档了吗?

  •  
  •   love · 2014-07-13 14:46:46 +08:00 · 6919 次点击
    这是一个创建于 3569 天前的主题,其中的信息可能已经有所发展或是发生改变。
    设startsecs=1, startretries=3(都是默认值),如果有一程序有这些行为:

    a) 启动即退出,exit code为0, 那么supervisor会在重试3试后停止重试,进程状态为FATAL。
    b) 启动即退出,exit code为1, 那么supervisor会在重试3试后停止重试,进程状态为FATAL。
    c) 启动3秒后退出,exit code为1, 那么supervisor会无限重启程序,无视startretries。
    d) 启动3秒后退出,exit code为0, 那么supervisor不会重启,进程状态为EXIT。

    abd都是预期行为,为什么c会无限重启呢?这好象不太合理啊?非正常退出不是应该重启3次吗?


    supervisor是debian 7自带的。

    autorestart

    May be one of false, unexpected, or true. If false, the process will never be autorestarted. If unexpected, the process will be restart when the program exits with an exit code that is not one of the exit codes associated with this process’ configuration (see exitcodes). If true, the process will be unconditionally restarted when it exits, without regard to its exit code.
    3 条回复    2016-03-23 18:11:47 +08:00
    love
        1
    love  
    OP
       2014-07-13 14:52:56 +08:00
    我操果然写出来才是理解问题的最好方式吗,刚发出来就马上理解了supervisor这么做的合理性了。
    试想一个程序会随机崩掉(比如每隔几天内存用光退出,这时exit code不为0),那种情况下是应该无限重启的,因为程序运行时间已经过了startsecs,认为是正常运行了,这时运行失败和启动不能运行失败是不同的性质。
    fising
        2
    fising  
       2016-03-23 18:09:59 +08:00
    谢谢,我也是看了你贴的东西顿悟了。
    fising
        3
    fising  
       2016-03-23 18:11:47 +08:00
    a 和 b 是启动未成功,重试启动 3 次(默认);
    c 是正常启动,但是未正常结束。所以不断重试。
    d 是正常启动,正常退出。不重试。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2685 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 10:17 · PVG 18:17 · LAX 03:17 · JFK 06:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.