]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/server/starlette/server.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / nominatim / server / starlette / server.py
index a2a70ebf0cb4a62c547ed618d6bae4c271b6dc0c..f81b122f274e17ddf0e0565139b09e003663a05e 100644 (file)
@@ -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)