X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/e1af6a22d357de51c86ac73582beba2b4419227b..7d911f9ffbdf63b2b2a45c3a3ee7063d006a5779:/nominatim/server/starlette/server.py?ds=sidebyside diff --git a/nominatim/server/starlette/server.py b/nominatim/server/starlette/server.py index a2a70ebf..f81b122f 100644 --- a/nominatim/server/starlette/server.py +++ b/nominatim/server/starlette/server.py @@ -78,7 +78,11 @@ def get_application(project_dir: Path, if config.get_bool('CORS_NOACCESSCONTROL'): middleware.append(Middleware(CORSMiddleware, allow_origins=['*'])) - app = Starlette(debug=debug, routes=routes, middleware=middleware) + async def _shutdown() -> None: + await app.state.API.close() + + app = Starlette(debug=debug, routes=routes, middleware=middleware, + on_shutdown=[_shutdown]) app.state.API = NominatimAPIAsync(project_dir, environ)