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

2014-07-13 14:46:46 +08:00
 love
设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.
6929 次点击
所在节点    Linux
3 条回复
love
2014-07-13 14:52:56 +08:00
我操果然写出来才是理解问题的最好方式吗,刚发出来就马上理解了supervisor这么做的合理性了。
试想一个程序会随机崩掉(比如每隔几天内存用光退出,这时exit code不为0),那种情况下是应该无限重启的,因为程序运行时间已经过了startsecs,认为是正常运行了,这时运行失败和启动不能运行失败是不同的性质。
fising
2016-03-23 18:09:59 +08:00
谢谢,我也是看了你贴的东西顿悟了。
fising
2016-03-23 18:11:47 +08:00
a 和 b 是启动未成功,重试启动 3 次(默认);
c 是正常启动,但是未正常结束。所以不断重试。
d 是正常启动,正常退出。不重试。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/122408

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX