-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shutdown supervisord once one of the programs is killed #712
Comments
You can achive this with an event listener: supervisord-watchdog:
Then add this config snippet:
|
That eventlistener snippet above was written for running supervisord in a docker container where it would have PID 1. You'll have to replace the kill commands with something suitable for your use case, like |
Writing an eventlistener similar to the one above is the recommended way to achieve this. More examples of eventlisteners can be found in the Superlance package. |
This is probably not the recommended way of shutting down supervisor but the following configuration has worked well for me. [program:something]
command = bash -c "something && kill -s SIGINT `cat supervisord.pid`"
stopasgroup = true
; other bits It will execute |
The watchdog script works well if none of the processes exit immediately -- I've been using something similar on my server for over a year. But if one of the processes exits before Supervisor starts the watchdog process (e.g. Nginx exits because its configuration file has a syntax error), then Supervisor continues to run. Setting @tillahoffmann 's solution avoids this problem, avoids running an extra process, and is much simpler. |
Note for maintainers: See additional comments in #1340. |
This issue was reopened in error. Usually when we need to watch processes and perform some configurable action based on their behavior, we implement those things in eventlisteners rather than supervisord itself. This was a design decision that was made a long time ago and why the eventlistener system came about. For example, it kept coming up that a subset of users wanted to monitor when a process uses "too much" memory and perform some action as a result. It was decided to keep that functionality in eventlisteners. The same points were raised in those tickets, e.g. some users do not want to run an extra eventlistener process. However, eventlisteners were written to do it and users run them. Overall, it seems to have worked out. Similarly here, some users want to monitor when a process does something and cause |
This is a great idea and helps me out. A minor issue: it would not make supevisord to exit by invoking |
the solution above #712 (comment) won't work if your program exists with a non 0 code it will equate to [program:something]
command = bash -c "something || kill -s SIGINT `cat supervisord.pid`"
stopasgroup = true
; other bits |
Hi,
I've two programs managed by supervisord.
Is there anyway to shutdown supervisord once of those programs is killed ?
The text was updated successfully, but these errors were encountered: