Skip to content

Commit f5382b8

Browse files
Hubert Pyskloclaude
authored andcommitted
Fix platform startup on Starlette 1.0 and register github service
- Convert the shutdown hook to a lifespan context manager so uvicorn boots on Starlette 1.0 (the decorator-based ``on_event`` hook was removed in that release and crashed ``create_app`` at import time). - Add ``github`` to the ``Service`` enum so ``initEnv`` accepts the GitHub templates that were landed alongside the service package. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9010023 commit f5382b8

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

backend/src/platform/api/main.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from contextlib import asynccontextmanager
2+
13
from sqlalchemy import create_engine
24
from sqlalchemy.pool import NullPool
35
from src.platform.isolationEngine.session import SessionManager
@@ -35,7 +37,13 @@
3537

3638

3739
def create_app():
38-
app = Starlette()
40+
@asynccontextmanager
41+
async def lifespan(app_):
42+
yield
43+
if getattr(app_.state, "replication_service", None):
44+
app_.state.replication_service.stop()
45+
46+
app = Starlette(lifespan=lifespan)
3947
db_url = environ["DATABASE_URL"]
4048

4149
# Use NullPool when using Neon's PgBouncer (-pooler) to avoid double pooling
@@ -143,12 +151,6 @@ def create_app():
143151

144152
app.mount("/api/env/{env_id}/services/linear", linear_graphql)
145153

146-
@app.on_event("shutdown")
147-
async def shutdown_event():
148-
# Stop replication service if running (it's on-demand now)
149-
if app.state.replication_service:
150-
app.state.replication_service.stop()
151-
152154
return app
153155

154156

backend/src/platform/api/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Service(str, Enum):
1313
linear = "linear"
1414
calendar = "calendar"
1515
box = "box"
16+
github = "github"
1617

1718

1819
class Visibility(str, Enum):

0 commit comments

Comments
 (0)