关于 supervisor 的 autorestart 为 unexpected 时(默认值)的行为好奇怪,是我理解错了文档了吗?
- 0次
- 2021-07-14 06:12:19
- idczone
设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.
我操果然写出来才是理解问题的最好方式吗,刚发出来就马上理解了supervisor这么做的合理性了。
试想一个程序会随机崩掉(比如每隔几天内存用光退出,这时exit code不为0),那种情况下是应该无限重启的,因为程序运行时间已经过了startsecs,认为是正常运行了,这时运行失败和启动不能运行失败是不同的性质。
谢谢,我也是看了你贴的东西顿悟了。
a 和 b 是启动未成功,重试启动 3 次(默认);
c 是正常启动,但是未正常结束。所以不断重试。
d 是正常启动,正常退出。不重试。