File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed
titiler-pgstac-api/runtime Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 22Handler for AWS Lambda.
33"""
44
5+ import asyncio
6+ import os
57from mangum import Mangum
68
79from .app import app
810
9- handler = Mangum (app )
11+ handler = Mangum (app , lifespan = "off" )
12+
13+
14+ if "AWS_EXECUTION_ENV" in os .environ :
15+ loop = asyncio .get_event_loop ()
16+ loop .run_until_complete (app .router .startup ())
Original file line number Diff line number Diff line change 1- titiler.pgstac == 0.3.3
1+ titiler.pgstac == 0.5.1
22boto3 >= 1.26.139
3- psycopg [binary, pool ]
3+ psycopg [binary, pool ]
Original file line number Diff line number Diff line change 22Handler for AWS Lambda.
33"""
44
5+ import asyncio
56import os
67from mangum import Mangum
78from utils import get_secret_dict
89from titiler .pgstac .main import app
10+ from titiler .pgstac .db import connect_to_db
911
1012pgstac_secret_arn = os .environ ["PGSTAC_SECRET_ARN" ]
1113
2022 }
2123)
2224
23- handler = Mangum (app )
25+
26+ @app .on_event ("startup" )
27+ async def startup_event () -> None :
28+ """Connect to database on startup."""
29+ await connect_to_db (app )
30+
31+
32+ handler = Mangum (app , lifespan = "off" )
33+
34+
35+ if "AWS_EXECUTION_ENV" in os .environ :
36+ loop = asyncio .get_event_loop ()
37+ loop .run_until_complete (app .router .startup ())
You can’t perform that action at this time.
0 commit comments