Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have Supervisord Periodically restart child processes

I am using Supervisor (3.0a12) on ubuntu 12.04 to manage php gearman workers. Sometimes the workers get caught in a weird state where they use tons of cpu and ram. While I am figuring this issue out I thought it would be nice to have Supervisor automatically kill and refresh workers occasionally. I looked at http://supervisord.org/configuration.html the configuration documentation and didn't seem to see any options that would allow for this.

Does anyone know if it is possible to have supervisord periodically restart all processes it governs??

like image 263
dm03514 Avatar asked Sep 24 '12 18:09

dm03514


People also ask

How do I restart my supervisord process?

To start a non-running service or stop a running one, use supervisorctl start my-daemon and supervisorctl stop my-daemon . To restart a service, you can also use supervisorctl restart my-daemon .

What is supervisord used for?

Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems. It shares some of the same goals of programs like launchd, daemontools, and runit.

How do I stop Supervisorctl?

Finally, you can exit supervisorctl with Ctrl+C or by entering quit into the prompt: supervisor> quit.

How does Supervisorctl work?

Supervisorctl allows a very limited form of access to the machine, essentially allowing users to see process status and control supervisord-controlled subprocesses by emitting “stop”, “start”, and “restart” commands from a simple shell or web UI.


2 Answers

You could use crontab to pass commands directly to supervisorctl. For example, the following will restart a process every 20 minutes.

0,20,40 * * * * /path/to/supervisorctl restart [supervisor_process] 
like image 70
scum Avatar answered Oct 18 '22 19:10

scum


The superlance package offers a memmon plugin for supervisor. memmon monitors memory usage for programs under supervisor control.

You configure memmon as a supervisor eventlistener:

[eventlistener:memmon] command=memmon -a 200MB events=TICK_60 

The above configuration sets memmon to restart any program under supervisor control if it exceeds 200MB memory usage. It checks every 60 seconds.

You can configure memmon to monitor specific programs or program groups, setting limits for each.

like image 33
Martijn Pieters Avatar answered Oct 18 '22 20:10

Martijn Pieters