jashdoshi77 commited on
Commit
21da995
·
1 Parent(s): db90335

fix: single worker + graceful table creation for Neon

Browse files
Files changed (2) hide show
  1. backend/app/main.py +23 -20
  2. supervisord.conf +1 -1
backend/app/main.py CHANGED
@@ -31,26 +31,29 @@ async def lifespan(app: FastAPI):
31
  logger.info("Starting %s v%s", settings.app_name, settings.app_version)
32
 
33
  # Create database tables
34
- async with engine.begin() as conn:
35
- from app.models import ( # noqa: F401 — force model registration
36
- Asset,
37
- BacktestResult,
38
- Exchange,
39
- Factor,
40
- FactorExposure,
41
- FeatureData,
42
- Holding,
43
- MarketplaceEntry,
44
- NewsArticle,
45
- Portfolio,
46
- PriceData,
47
- ResearchReport,
48
- Signal,
49
- Strategy,
50
- User,
51
- )
52
- await conn.run_sync(Base.metadata.create_all)
53
- logger.info("Database tables created successfully")
 
 
 
54
 
55
  # Seed exchange data
56
  await _seed_exchanges()
 
31
  logger.info("Starting %s v%s", settings.app_name, settings.app_version)
32
 
33
  # Create database tables
34
+ try:
35
+ async with engine.begin() as conn:
36
+ from app.models import ( # noqa: F401 — force model registration
37
+ Asset,
38
+ BacktestResult,
39
+ Exchange,
40
+ Factor,
41
+ FactorExposure,
42
+ FeatureData,
43
+ Holding,
44
+ MarketplaceEntry,
45
+ NewsArticle,
46
+ Portfolio,
47
+ PriceData,
48
+ ResearchReport,
49
+ Signal,
50
+ Strategy,
51
+ User,
52
+ )
53
+ await conn.run_sync(Base.metadata.create_all)
54
+ logger.info("Database tables created successfully")
55
+ except Exception as e:
56
+ logger.warning("Table creation skipped (tables may already exist): %s", e)
57
 
58
  # Seed exchange data
59
  await _seed_exchanges()
supervisord.conf CHANGED
@@ -15,7 +15,7 @@ stderr_logfile=/dev/stderr
15
  stderr_logfile_maxbytes=0
16
 
17
  [program:uvicorn]
18
- command=uvicorn app.main:app --host 127.0.0.1 --port 8000 --workers 2 --timeout-keep-alive 120
19
  directory=/app
20
  autostart=true
21
  autorestart=true
 
15
  stderr_logfile_maxbytes=0
16
 
17
  [program:uvicorn]
18
+ command=uvicorn app.main:app --host 127.0.0.1 --port 8000 --workers 1 --timeout-keep-alive 120
19
  directory=/app
20
  autostart=true
21
  autorestart=true