简体   繁体   English

使用supervisord比monit有什么好处

[英]what is the advantage of using supervisord over monit

We have a custom setup which has several daemons (web apps + background tasks) running. 我们有一个自定义设置,它有几个守护进程(Web应用程序+后台任务)运行。 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. 我正在寻找使用一种服务,它可以帮助我们监视这些守护进程,并在资源消耗超过一个级别时重新启动它们。

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. 据我所知,monit会在supervisord启动子流程时旋转一个新进程。 What is the pros and cons of this approach ? 这种方法的优点和缺点是什么?

I will also be using upstart to monitor monit or supervisord itself. 我也将使用暴发来监控monit或supervisord本身。 The webapp deployment will be done using capistrano. webapp部署将使用capistrano完成。

Thanks 谢谢

I haven't used monit but there are some significant flaws with supervisord. 我没有使用monit但是有一些重要的缺陷与supervisord。

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

This means you can't just execute /etc/init.d/apache2 start. 这意味着你不能只执行/etc/init.d/apache2 start。 Most times you can just write a one liner eg "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND" but sometimes you need your own wrapper script. 大多数情况下,您只需编写一个内容,例如“source / etc / apache2 / envvars && exec / usr / sbin / apache2 -DFOREGROUND”,但有时您需要自己的包装器脚本。 The problem with wrapper scripts is that you end up with two processes, a parent and child. 包装器脚本的问题在于您最终得到两个进程,父进程和子进程。 See the the next flaw... 看下一个缺陷......

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

If your program starts child process, supervisord wont detect this. 如果你的程序启动子进程,supervisord就不会检测到这一点。 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. 如果父进程死亡(或者如果它使用supervisorctl重新启动)子进程继续运行,但将由init进程“采用”并保持运行。 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. 最近的配置选项stopasgroup和killasgroup应该解决这个问题,但对我来说不起作用。

  1. supervisord has no dependency management - see #122 supervisord没有依赖管理 - 见#122

I recently setup squid with qlproxy. 我最近用qlproxy设置了squid。 qlproxyd needs to start first otherwise squid can fail. qlproxyd需要先启动,否则squid会失败。 Even though both programs were managed with supervisord there was no way to ensure this. 尽管这两个程序都是用supervisord管理的,但是没有办法确保这一点。 I needed to write a start script for squid that made it wait for the qlproxyd process. 我需要为squid编写一个启动脚本,使其等待qlproxyd进程。 Adding the start script resulted in the orphaned process problem described in flaw 2 添加启动脚本导致了漏洞2中描述的孤立进程问题

  1. supervisord doesn't allow you to control the delay between startretries supervisord不允许您控制startretries之间的延迟

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. 在重新启动之间,进程将进入“BACKOFF”状态,但是没有文档或控制退避的持续时间。

In its defence supervisor does meet our needs 80% of the time. 在其国防主管确实80%的时间满足我们的需求。 The configuration is sensible and documentation pretty good. 配置合理,文档非常好。

If you want to additionally monitor resources you should settle for monit. 如果你想要额外监控资源,你应该接受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). 除了检查进程是否正在运行(可用性)之外,monit还可以执行一些资源使用(性能,容量使用),负载级别甚至基本安全检查(bianry文件的md5sum,配置文件等)的检查。 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 还有很多可以使用的配置: 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. Monit需要进程来创建PID文件,这可能是一个缺陷,因为如果一个进程没有创建pid文件,你必须创建一些包装器。 See http://mmonit.com/wiki/Monit/FAQ#pidfile 请参阅http://mmonit.com/wiki/Monit/FAQ#pidfile

Supervisord on the other hand is more bound to a process, it spawns it by itself. 另一方面,Supervisord更多地受制于一个过程,它自己产生它。 It cannot make any resource based checks as monit. 它不能将任何基于资源的检查作为监控。 It has a nice CLI servicectl and a web GUI though. 它有一个很好的CLI servicectl和Web GUI。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM