使用监督的优点是什么?

时间:2022-06-01 14:56:28

We have a custom setup which has several daemons (web apps + background tasks) running. I am looking at using a service which helps us to monitor those daemons and restart them if their resource consumption exceeds over a level.

我们有一个自定义设置,其中有几个守护进程(web应用程序+后台任务)正在运行。我正在考虑使用一个服务,它帮助我们监控这些守护进程,如果它们的资源消耗超过了一个级别,就重新启动它们。

I will appreciate any insight on when one is better over the other. As I understand monit spins up a new process while supervisord starts a sub process. What is the pros and cons of this approach ?

我将欣赏任何关于何时一个比另一个更好的见解。据我所知,monit生成了一个新的进程,而monitsord启动了一个子进程。这种方法的利弊是什么?

I will also be using upstart to monitor monit or supervisord itself. The webapp deployment will be done using capistrano.

我还将使用upstart来监视monit或监管自己。webapp的部署将使用capistrano完成。

Thanks

谢谢

2 个解决方案

#1


29  

I haven't used monit but there are some significant flaws with supervisord.

我没有使用过monit,但是有一些明显的缺陷。

  1. Programs should run in the foreground
  2. 程序应该在前台运行

This means you can't just execute /etc/init.d/apache2 start. Most times you can just write a one liner e.g. "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND" but sometimes you need your own wrapper script. The problem with wrapper scripts is that you end up with two processes, a parent and child. See the the next flaw...

这意味着你不能只执行/etc/ initit。d /输入的开始。大多数情况下,你可以只写一行。“源/etc/apache2/ envars & exec /usr/sbin/apache2 - d前台”,但有时您需要自己的包装脚本。包装器脚本的问题是您最终会得到两个进程,父进程和子进程。看下一个缺陷……

  1. supervisord does not manage child processes
  2. monitor sord不管理子进程

If your program starts child process, supervisord wont detect this. If the parent process dies (or if it's restarted using supervisorctl) the child processes keep running but will be "adopted" by the init process and stay running. This might prevent future invocations of your program running or consume additional resources. The recent config options stopasgroup and killasgroup are supposed to fix this, but didn't work for me.

如果你的程序启动了子进程,那么监督者不会发现这一点。如果父进程死亡(或者如果使用monitsorctl重新启动),子进程将继续运行,但将被init进程“采用”并继续运行。这可能会阻止将来对正在运行的程序的调用或消耗额外的资源。最近的配置选项stopasgroup和killasgroup本来应该解决这个问题,但对我来说并不适用。

  1. supervisord has no dependency management - see #122
  2. 监督者没有依赖管理-见第122条

I recently setup squid with qlproxy. qlproxyd needs to start first otherwise squid can fail. Even though both programs were managed with supervisord there was no way to ensure this. I needed to write a start script for squid that made it wait for the qlproxyd process. Adding the start script resulted in the orphaned process problem described in flaw 2

我最近用qlproxy设置了乌贼。qlproxyd需要先开始,否则乌贼会失败。即使这两个项目都是在监督下管理的,也没有办法保证这一点。我需要为squid编写一个开始脚本,让它等待qlproxyd过程。添加开始脚本导致了缺陷2中描述的孤立过程问题

  1. supervisord doesn't allow you to control the delay between startretries
  2. 监督者不允许你控制星际之间的延迟

Sometimes when a process fails to start (or crashes), it's because it can't get access to another resource, possibly due to a network wobble. Supervisor can be set to restart the process a number of times. Between restarts the process will enter a "BACKOFF" state but there's no documentation or control over the duration of the backoff.

有时,当一个进程无法启动(或崩溃)时,这是因为它无法访问另一个资源,可能是由于网络抖动。可以多次设置Supervisor以重新启动流程。在重新启动期间,进程将进入“备份”状态,但在备份期间没有任何文档或控制。

In its defence supervisor does meet our needs 80% of the time. The configuration is sensible and documentation pretty good.

在它的国防主管中,有80%的时间满足我们的需要。配置是合理的,文档也很好。

#2


28  

If you want to additionally monitor resources you should settle for monit. In addition to just checking whether a process is running (availability), monit can also perform some checks of resource usage (performance, capacity usage), load levels and even basic security checks (md5sum of a bianry file, config file, etc). It has a rule-based config which is quite easy to comprehend. Also there is a lot of ready to use configs: http://mmonit.com/wiki/Monit/ConfigurationExamples

如果您想要额外监控资源,您应该选择monit。除了检查进程是否正在运行(可用性)之外,monit还可以执行一些资源使用检查(性能、容量使用)、负载级别甚至基本安全检查(bianry文件的md5sum、配置文件等)。它有一个基于规则的配置,很容易理解。还有很多已经准备好使用configs: http://mmonit.com/wiki/Monit/ConfigurationExamples

Monit requires processes to create PID files, which can be a flaw, because if a process does not create pid file you have to create some wrappers around. See http://mmonit.com/wiki/Monit/FAQ#pidfile

Monit需要进程来创建PID文件,这可能是一个缺陷,因为如果进程不创建PID文件,就必须创建一些包装器。看到http://mmonit.com/wiki/Monit/FAQ pidfile

Supervisord on the other hand is more bound to a process, it spawns it by itself. It cannot make any resource based checks as monit. It has a nice CLI servicectl and a web GUI though.

另一方面,监督者更倾向于一个过程,它自己产生它。它不能将任何基于资源的检查作为monit。不过,它有一个不错的CLI servicectl和一个web GUI。

#1


29  

I haven't used monit but there are some significant flaws with supervisord.

我没有使用过monit,但是有一些明显的缺陷。

  1. Programs should run in the foreground
  2. 程序应该在前台运行

This means you can't just execute /etc/init.d/apache2 start. Most times you can just write a one liner e.g. "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND" but sometimes you need your own wrapper script. The problem with wrapper scripts is that you end up with two processes, a parent and child. See the the next flaw...

这意味着你不能只执行/etc/ initit。d /输入的开始。大多数情况下,你可以只写一行。“源/etc/apache2/ envars & exec /usr/sbin/apache2 - d前台”,但有时您需要自己的包装脚本。包装器脚本的问题是您最终会得到两个进程,父进程和子进程。看下一个缺陷……

  1. supervisord does not manage child processes
  2. monitor sord不管理子进程

If your program starts child process, supervisord wont detect this. If the parent process dies (or if it's restarted using supervisorctl) the child processes keep running but will be "adopted" by the init process and stay running. This might prevent future invocations of your program running or consume additional resources. The recent config options stopasgroup and killasgroup are supposed to fix this, but didn't work for me.

如果你的程序启动了子进程,那么监督者不会发现这一点。如果父进程死亡(或者如果使用monitsorctl重新启动),子进程将继续运行,但将被init进程“采用”并继续运行。这可能会阻止将来对正在运行的程序的调用或消耗额外的资源。最近的配置选项stopasgroup和killasgroup本来应该解决这个问题,但对我来说并不适用。

  1. supervisord has no dependency management - see #122
  2. 监督者没有依赖管理-见第122条

I recently setup squid with qlproxy. qlproxyd needs to start first otherwise squid can fail. Even though both programs were managed with supervisord there was no way to ensure this. I needed to write a start script for squid that made it wait for the qlproxyd process. Adding the start script resulted in the orphaned process problem described in flaw 2

我最近用qlproxy设置了乌贼。qlproxyd需要先开始,否则乌贼会失败。即使这两个项目都是在监督下管理的,也没有办法保证这一点。我需要为squid编写一个开始脚本,让它等待qlproxyd过程。添加开始脚本导致了缺陷2中描述的孤立过程问题

  1. supervisord doesn't allow you to control the delay between startretries
  2. 监督者不允许你控制星际之间的延迟

Sometimes when a process fails to start (or crashes), it's because it can't get access to another resource, possibly due to a network wobble. Supervisor can be set to restart the process a number of times. Between restarts the process will enter a "BACKOFF" state but there's no documentation or control over the duration of the backoff.

有时,当一个进程无法启动(或崩溃)时,这是因为它无法访问另一个资源,可能是由于网络抖动。可以多次设置Supervisor以重新启动流程。在重新启动期间,进程将进入“备份”状态,但在备份期间没有任何文档或控制。

In its defence supervisor does meet our needs 80% of the time. The configuration is sensible and documentation pretty good.

在它的国防主管中,有80%的时间满足我们的需要。配置是合理的,文档也很好。

#2


28  

If you want to additionally monitor resources you should settle for monit. In addition to just checking whether a process is running (availability), monit can also perform some checks of resource usage (performance, capacity usage), load levels and even basic security checks (md5sum of a bianry file, config file, etc). It has a rule-based config which is quite easy to comprehend. Also there is a lot of ready to use configs: http://mmonit.com/wiki/Monit/ConfigurationExamples

如果您想要额外监控资源,您应该选择monit。除了检查进程是否正在运行(可用性)之外,monit还可以执行一些资源使用检查(性能、容量使用)、负载级别甚至基本安全检查(bianry文件的md5sum、配置文件等)。它有一个基于规则的配置,很容易理解。还有很多已经准备好使用configs: http://mmonit.com/wiki/Monit/ConfigurationExamples

Monit requires processes to create PID files, which can be a flaw, because if a process does not create pid file you have to create some wrappers around. See http://mmonit.com/wiki/Monit/FAQ#pidfile

Monit需要进程来创建PID文件,这可能是一个缺陷,因为如果进程不创建PID文件,就必须创建一些包装器。看到http://mmonit.com/wiki/Monit/FAQ pidfile

Supervisord on the other hand is more bound to a process, it spawns it by itself. It cannot make any resource based checks as monit. It has a nice CLI servicectl and a web GUI though.

另一方面,监督者更倾向于一个过程,它自己产生它。它不能将任何基于资源的检查作为monit。不过,它有一个不错的CLI servicectl和一个web GUI。