geobakery / GeospatialAnalyzer

GeospatialAnalyzer HTTP-API
GNU General Public License v3.0
3 stars 0 forks source link

Start application while database is not available #12

Open dschlarmann opened 9 months ago

dschlarmann commented 9 months ago

Currently, the application fails to start if the underlying database is not available. The following output is logged:

[Nest] 32400  - 17.01.2024, 21:11:29   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (2)...
AggregateError:
    at internalConnectMultiple (node:net:1114:18)
    at afterConnectMultiple (node:net:1667:5)

It would be nice if the application would start anyway.

dschlarmann commented 9 months ago

As far as I can see there is no option to realize this requirement. The underlying TypeORM module does not offer the needed functionality. More information here: https://stackoverflow.com/a/74046031/2873979

As an workaround we could increase the maximum retries as well as retriesDelay. Of course this does not solve the actual problem, but it would offer a softer behavior. Check the following docs: https://docs.nestjs.com/techniques/database#typeorm-integration --> Properties retryAttempts and retryDelay

Keep in mind: We should not set the above mentioned properties to an infinite value, since this would only result a later error. If the database is not available, the database itself properly won't be available later on. Instead we should check the "operational" approaches using Rancher, kubernetes, ingress, ....