V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
love
V2EX  ›  Linux

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

  •  
  •   love · Jul 13, 2014 · 7461 views
    This topic created in 4306 days ago, the information mentioned may be changed or developed.
    设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 replies    2016-03-23 18:11:47 +08:00
    love
        1
    love  
    OP
       Jul 13, 2014
    我操果然写出来才是理解问题的最好方式吗,刚发出来就马上理解了supervisor这么做的合理性了。
    试想一个程序会随机崩掉(比如每隔几天内存用光退出,这时exit code不为0),那种情况下是应该无限重启的,因为程序运行时间已经过了startsecs,认为是正常运行了,这时运行失败和启动不能运行失败是不同的性质。
    fising
        2
    fising  
       Mar 23, 2016
    谢谢,我也是看了你贴的东西顿悟了。
    fising
        3
    fising  
       Mar 23, 2016
    a 和 b 是启动未成功,重试启动 3 次(默认);
    c 是正常启动,但是未正常结束。所以不断重试。
    d 是正常启动,正常退出。不重试。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3200 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 13:39 · PVG 21:39 · LAX 06:39 · JFK 09:39
    ♥ Do have faith in what you're doing.