Don't exit on database connection error
It seems that in here after 10 retries you just exit the application. In case of a temporary database issue or maintenance, having to restart the apps is usually a bad practice. I think an exponential back-off would be more suited than exiting.