To configure Supervisor to restart failed worker processes, you can use the following steps:
1. Configure the Supervisor Configuration File:
- Edit the Supervisor configuration file (`supervisord.conf`) to specify the worker processes and their restart behavior.
2. Restart Behavior:
- Set the `autorestart` option to `true` to automatically restart the worker process if it fails.
3. Restart Delay:
- Set the `startretries` option to specify the number of times the worker process should be restarted before it is considered failed.
4. Restart Delay Between Failures:
- Set the `startdelay` option to specify the delay between restart attempts.
5. Restart Behavior on Failure:
- Set the `stopwaitsecs` option to specify the time to wait before stopping the worker process if it fails.
Here is an example configuration:
bash
[program:worker]
command=/path/to/worker
autorestart=true
startretries=3
startdelay=10
stopwaitsecs=30
This configuration will restart the worker process three times if it fails, with a 10-second delay between restart attempts. If the worker process fails to start after three attempts, it will be considered failed and stopped.
By configuring Supervisor in this way, you can ensure that failed worker processes are automatically restarted, ensuring continuous operation of your application.
Citations:[1] https://stackoverflow.com/questions/12571052/have-supervisord-periodically-restart-child-processes
[2] https://superuser.com/questions/1207265/supervisor-not-restarting-the-process
[3] https://elixirforum.com/t/how-to-make-a-supervisor-never-die/22734
[4] https://github.com/Supervisor/supervisor/issues/600
[5] https://serverfault.com/questions/528264/using-supervisord-how-can-i-start-a-brand-new-worker-via-supervisorctl-without