X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/f8bca4fbcb739daa6a89dd52c219713dd1173287..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)