bug fixes for local deployment model
This commit is contained in:
+1
-1
@@ -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
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user