bug fixes for local deployment model

This commit is contained in:
2026-06-28 14:37:24 -07:00
parent 621e8bd7b6
commit 8ef1ac12c7
3 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -16,4 +16,4 @@ RUN mkdir -p /app/geo
COPY geo/ /app/geo/
EXPOSE 8000
CMD ["gunicorn", "app.main:app", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:8000", "--workers", "2", "--timeout", "120"]
CMD ["gunicorn", "app.main:app", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:8000", "--workers", "1", "--timeout", "120"]
+8 -2
View File
@@ -106,7 +106,13 @@ async def lifespan(app: FastAPI):
# Create tables on startup, then patch any missing columns
async with engine.begin() as conn:
await conn.run_sync(_cleanup_orphaned_sequences)
await conn.run_sync(Base.metadata.create_all)
try:
await conn.run_sync(Base.metadata.create_all)
except Exception as e:
if "duplicate" in str(e).lower():
print(f" → Tables already exist (partial creation from prior restart): {e}")
else:
raise
await conn.run_sync(_migrate_add_missing_columns)
# Auto-seed if database is empty
@@ -117,7 +123,7 @@ async def lifespan(app: FastAPI):
print(" → Database is empty — running seed...")
from seed import seed as run_seed
await run_seed()
return # Full seed already included station config
print(" ✓ Full seed completed (skipping station config check)")
# Ensure station config exists (runs even if DB already had data)
async with async_session() as session:
+3
View File
@@ -2,6 +2,9 @@
# Render config templates with environment variables, then start nginx.
set -e
# Ensure nginx can write to the shared logs directory
mkdir -p /logs && chown nginx:nginx /logs
sed "s|__API_UPSTREAM__|${API_UPSTREAM}|g" /etc/nginx/conf.d/nginx.conf.template > /etc/nginx/conf.d/default.conf
envsubst '${API_PUBLIC_URL}' < /usr/share/nginx/html/config.json.template > /usr/share/nginx/html/config.json