我在ubuntu 12.04上使用Supervisor (3.0a12)来管理php gearman worker。 有时,工人们会陷入一种奇怪的状态,他们使用了大量的cpu和ram.当我正在解决这个问题时,我想让Supervisor自动杀死和刷新工人。 当我在解决这个问题时,我想如果能让Supervisor偶尔自动杀死和刷新工人就更好了。 我看了一下 http:/supervisord.orgconfiguration.html。 的配置文档,但似乎没有看到任何允许这样做的选项。
有谁知道是否可以让supervisord定期重启它所管理的所有进程?
我是 superlance
包裹 提供 memmon
插件 为上级程序。memmon
监控上级控制下的程序的内存使用情况。
您可以配置 memmon
作为上级事件监听器。
[eventlistener:memmon]
command=memmon -a 200MB
events=TICK_60
以上配置将memmon设置为重启 任何 如果上级控制下的程序超过200MB的内存使用量,它就会进行检查。它每60秒检查一次。
你可以配置memmon来监视特定的程序或程序组,为每个程序设置限制。
你可以使用crontab直接向supervisorctl传递命令。 例如,以下命令将每20分钟重新启动一个进程。
0,20,40 * * * * /path/to/supervisorctl restart [supervisor_process]
有一个简单的只针对supervisor的解决方案。再做一个supervisor进程,在适当的时间内睡眠,然后重新启动你想要的进程。
[program:my_program]
process_name = python something.py
[program:periodicrestarter]
command = sh -c "echo 'restart my_program' | supervisorctl;sleep 600"
; restarts all (sleeps first because this restarts itself):
;command = sh -c "sleep 600; echo 'restart all' | supervisorctl"
autorestart = true