willfarrell / docker-autoheal

Monitor and restart unhealthy docker containers.
MIT License
1.3k stars 225 forks source link

Question: Restart if unhealthy for more than x mins? #78

Open edrock200 opened 2 years ago

edrock200 commented 2 years ago

Is it possible to configure autoheal to restart only if container is unhealthy for more than x mins? I have a container which has a db optimize routine which can sometimes make the container unresponsive and trigger an "unhealthy" state for a few minutes. As soon as it's done, the container goes healthy. Is there a way to tell autoheal "only restart if unhealthy for greater than x mins?" Thanks in advance. Ed

fracai commented 2 years ago

Wouldn't it be more appropriate to set the health check configuration to only show unhealthy after those "few minutes"? You have:

edrock200 commented 2 years ago

Understood, I don't think I will convince plex of changing it, but I'll give it a shot. :) Thanks again.

RXWatcher commented 2 years ago

With compose you can overwrite the default health check with your own to extend the health check or what I do is script the optimize.

Stop autoheal Optimize Start autoheal

You're talking just a couple of minutes while the optimize completes.

Im not going to give away the code as I didn't write it and its not my place to do so.

On Thu, Feb 24, 2022, 07:23 edrock200 @.***> wrote:

Understood, I don't think I will convince plex of changing it, but I'll give it a shot. :) Thanks again.

— Reply to this email directly, view it on GitHub https://github.com/willfarrell/docker-autoheal/issues/78#issuecomment-1049533300, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADLOXCN3DDAUT5TAOFESMGDU4XFFPANCNFSM5LBN232A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

edrock200 commented 2 years ago

Oh I already have a script that does that, would just be nice to extend the timeout via autoheal. For others that want to do it it's just a simple bash script:

docker stop autoheal
curl -X PUT http://plexURL:32400/library/optimize?X-Plex-Token=plextoken
sleep 5m
docker start autoheal

Sub in your plex url and token and just cron that.