English 中文(简体)
那么,谁应该守护呢?脚本还是调用方?
原标题:
  • 时间:2008-09-24 13:26:03
  •  标签:

我一直在想谁应该这么做。在Ruby,我们有Daemons库,它允许Ruby脚本对自己进行守护。然后,查看God(一种流程监控工具,类似于monit)页面,我看到上帝可以守护进程。

有明确的答案吗?

最佳回答

你可能无法得到一个明确的答案,因为我们通常会同时得到这两个答案:进程有能力守护自己,进程监视器有能力守护它的子进程。

Personally I prefer to have the process monitor or script do it, for a few reasons:
1. if the process monitor wishes to closely follow its children to restart them if they die, it can choose not to daemonize them. A SIGCHLD will be delivered to the monitor when one of its child processes exits. In embedded systems we do this a lot.
2. Typically when daemonizing, you also set the euid and egid. I prefer not to encode into every child process a knowledge of system-level policy like uids to use.
3. It allows re-use of the same application as either a command line tool or a daemon (I freely admit that this rarely happens in practice).

问题回答

我想说最好由脚本来完成。我不知道你的流程监控工具,但我认为用户可能会使用另一种工具,这意味着让脚本来完成它会更好。

如果您可以设想脚本以非守护程序的方式运行,我会在脚本中添加一个选项来启用或禁用守护程序化。





相关问题
热门标签