Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: update titiler version and fix lifespan #61

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
Loading