pelias / api

HTTP API for Pelias Geocoder
http://pelias.io
MIT License
218 stars 162 forks source link

Add option to quit on type mapping discovery errors #1624

Closed orangejulius closed 2 years ago

orangejulius commented 2 years ago

This adds a new config option, api.targets.auto_discover_required. If set to true, the API will quit with a fatal error if there is any problem performing the type mapping discovery.

In practice what this means is a working Elasticsearch cluster with a valid Pelias index must exist and be properly configured in pelias.json, or the API won't start.

This can actually be quite helpful in production environments as it can protect against misconfiguration issues such as using the wrong URL to the Elasticsearch cluster.

Because the check is only performed once at startup, it won't cause the API to quit if there's an intermittent network issue or something similar later on.

This PR includes the changes from #1625 so the Express webserver does not even start until the TypeMapping has been loaded. That means there's zero chance of any requests being served without correct config information.

Connects https://github.com/pelias/api/issues/1591 Connects https://github.com/pelias/pelias/issues/925