Skip to content

Commit a80ec05

Browse files
committed
Fix deployment?
1 parent 3a41eca commit a80ec05

3 files changed

Lines changed: 22 additions & 25 deletions

File tree

backend/Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ USER app
8888
# Ensure the virtual environment is in PATH
8989
ENV PATH="/app/.venv/bin:$PATH"
9090

91-
# Default port for local/dev. Platforms like Cloud Run will inject $PORT.
92-
ENV PORT=8000
93-
9491
# Document the port; EXPOSE is informational for most orchestrators
9592
EXPOSE 8000
9693

backend/app/__init__.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,12 @@ async def lifespan(app: FastAPI):
2222
setup_logging()
2323
logger = get_logger("app", component="application")
2424

25-
# Initialize database pool with retry and timeout
25+
# Initialize database pool
2626
from db.pool import database_pool
27-
import asyncio
28-
29-
try:
30-
# Try to connect to database with timeout
31-
await asyncio.wait_for(
32-
database_pool.setup(logger=logger),
33-
timeout=10.0, # 10 second timeout for database connection
34-
)
35-
logger.info("Database connection established successfully")
36-
except asyncio.TimeoutError:
37-
logger.warning("Database connection timed out during startup - continuing without database")
38-
except Exception as e:
39-
logger.warning(f"Database connection failed during startup: {e} - continuing without database")
40-
41-
# Ensure temporary directory exists
27+
28+
await database_pool.setup(logger=logger)
29+
30+
# Create tmp directories
4231
from core.config import settings
4332

4433
settings.tmp_dir.mkdir(parents=True, exist_ok=True)
@@ -55,10 +44,7 @@ async def lifespan(app: FastAPI):
5544
yield
5645

5746
# Shutdown
58-
try:
59-
await database_pool.close()
60-
except Exception as e:
61-
logger.warning(f"Error closing database pool: {e}")
47+
await database_pool.close()
6248
logger.info("App shutdown complete")
6349

6450

backend/cloudbuild.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ steps:
4646
id: 'push-backend'
4747
waitFor: [ 'build-backend' ]
4848

49-
# Deploy backend to Cloud Run (only waits for push, not cleanup)
49+
# Deploy backend to Cloud Run (waits for push to complete)
5050
- name: 'gcr.io/cloud-builders/gcloud'
5151
args:
5252
- 'run'
@@ -74,7 +74,21 @@ steps:
7474
- '--timeout'
7575
- '$_TIMEOUT'
7676
id: 'deploy-backend'
77-
waitFor: [ 'push-backend' ] # Only wait for push to complete, cleanup can continue in parallel
77+
waitFor: [ 'push-backend' ] # Wait for push to complete fully
78+
79+
# Verify deployment completed successfully
80+
- name: 'gcr.io/cloud-builders/gcloud'
81+
args:
82+
- 'run'
83+
- 'services'
84+
- 'describe'
85+
- 'ai-slop-backend'
86+
- '--region'
87+
- '$_REGION'
88+
- '--format'
89+
- 'value(status.url)'
90+
id: 'verify-deployment'
91+
waitFor: [ 'deploy-backend' ] # Wait for deployment to complete
7892

7993
# Set timeout for the entire build
8094
timeout: 3600s

0 commit comments

Comments
 (0)