tubesync
tubesync copied to clipboard
Database connection retry
Hi there,
Is there a way to get tubesync to retry connections to MySQL when it boots? Scenario is, I run docker on my Synology NAS and it boots all containers up at the same time (something I can't control AFAIK). MySQL doesn't start up before tubesync tries to connect to it. Is there a way of getting tubesync to retry say 10 times with a 1 minute gap between retries? Or even to restart the container upon failure?
Thanks
V
The tubesync services should retry the database connection eventually, what's failing exactly? Usually, you would handle this by using service order in a docker-compose
file or similar dependency ordering: https://docs.docker.com/compose/startup-order/ but I've never used a Synology NAS and the documentation doesn't seem to support this so perhaps it's just a missing feature of your Synology. If your platform supports it you can use the healthcheck which reports the container health (and will fail if the database is unreachable) as a trigger to restart the container.
Synology version of docker is basically a frontend. While docker can be manipulated using the command line, it's not the greatest. I have attached the log of the issue to see if it's easy to overcome. tubesync.txt
If you just put restart: unless-stopped
or whatever the equivalent is on your container that should fix itself once the container restarts. If not, this is really more of a Synology and hosting containers question than a tubesync question. The container should kill itself if start-up fails with a non-functioning database connection. How it restarts is up to the platform running the container. From a brief search about it seems the generally accepted way to solve this on Synology is to use docker-compose
and the command line.
OK I've set that setting, but I'm not 100% on how that will help, as that setting is on boot/start of the docker subsystem (at least I'm pretty sure it is!), not if there is an issue within the container. I do have Portainer going, so if there is something you can think of in there that could help, that would be awesome please :)
Yeah that restart setting is only going to help if you can set it at the container level. If you can't them I'm afraid the general advice is going to be use the shell and a docker-compose
script to be able to set up container dependencies properly, or I suppose wait for Synology to update their web interface with more features.
Edit: this looks like a reasonably comprehensive guide https://linuxhint.com/docker-compose-with-synology/
It is set at the container level. I guess I was looking to see if there was a simple way for you to put a delay retry on the database connection on startup. If the answer is no, then it's no.
There isn't a sensible way to introduce a delay, no. Also a delay would the wrong way to solve this, just waiting an arbitrary time before connecting is a hack that would not actually fix the issue (just most of the time, not all of the time) and introduce other more subtle problems.
OK thanks mate, I'll look into that site you mentioned and see if I can work out another way of getting this working.