ShokoServer
ShokoServer copied to clipboard
Retry connecting to database when starting
So when I reboot my system I always have to restart the Shoko server because the database wasn't available yet when Shoko started. So it would be nice if Shoko server could try to start again after an preset interval.
You can trigger it via api
Yeah, but can it be automated? Now I need to remember every time I reboot I have restart Shoko. Running on Docker btw.
You can just use docker-compose and use https://docs.docker.com/compose/compose-file/#depends_on
On Wed, Jun 19, 2019, 8:12 AM Dexil123 [email protected] wrote:
Yeah, but can it be automated? Now I need to remember every time I reboot I have restart Shoko. Running on Docker btw.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ShokoAnime/ShokoServer/issues/790?email_source=notifications&email_token=AAHSXJUUO3D74ERUIUKVDALP3FMUBA5CNFSM4HZEHIEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYADVBQ#issuecomment-503331462, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHSXJQ5M4LZCARPNJBGCS3P3FMUBANCNFSM4HZEHIEA .
I have tried depends on but it doesn't wait until the database is ready. So Shoko is still starting right after it the database container is running but the database is not accessible yet.
See also:
https://docs.docker.com/compose/startup-order/
"However, for startup Compose does not wait until a container is “ready” (whatever that means for your particular application) - only until it’s running. "
Just found this and hope this will be helpful even if the last post is from Feb 2021.
For Shoko I use this in my compose file:
depends_on:
mariadb:
condition: service_healthy
For the DB I added a custom healthcheck so it actually returns a healthy status when it's up:
healthcheck:
test: "/usr/bin/mysql --user=<youruser> --password=<yourpassword> --execute \"SHOW DATABASES;\""
start_period: 1m
interval: 30s
timeout: 2s
retries: 5
maybe you can work with this for your compose file
It'll already retry for a minute. https://github.com/ShokoAnime/ShokoServer/blob/984ddf7a43f8bcf7d33dfbc2d8525a8b6d43151f/Shoko.Server/Databases/DatabaseFactory.cs#L79