Skip to content

Commit

Permalink
feat!: update titiler version and fix lifespan
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Aug 3, 2023
1 parent 402c784 commit aa67363
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
9 changes: 8 additions & 1 deletion lib/stac-api/runtime/src/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
Handler for AWS Lambda.
"""

import asyncio
import os
from mangum import Mangum

from .app import app

handler = Mangum(app)
handler = Mangum(app, lifespan="off")


if "AWS_EXECUTION_ENV" in os.environ:
loop = asyncio.get_event_loop()
loop.run_until_complete(app.router.startup())
4 changes: 2 additions & 2 deletions lib/titiler-pgstac-api/runtime/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
titiler.pgstac==0.3.3
titiler.pgstac==0.5.1
boto3>=1.26.139
psycopg[binary, pool]
psycopg[binary, pool]
16 changes: 15 additions & 1 deletion lib/titiler-pgstac-api/runtime/src/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
Handler for AWS Lambda.
"""

import asyncio
import os
from mangum import Mangum
from utils import get_secret_dict
from titiler.pgstac.main import app
from titiler.pgstac.db import connect_to_db

pgstac_secret_arn = os.environ["PGSTAC_SECRET_ARN"]

Expand All @@ -20,4 +22,16 @@
}
)

handler = Mangum(app)

@app.on_event("startup")
async def startup_event() -> None:
"""Connect to database on startup."""
await connect_to_db(app)


handler = Mangum(app, lifespan="off")


if "AWS_EXECUTION_ENV" in os.environ:
loop = asyncio.get_event_loop()
loop.run_until_complete(app.router.startup())

0 comments on commit aa67363

Please sign in to comment.