Fix deploy.py: Worker-Deploy war kaputt
- Bug 1: WORKER_COMPOSE_YAML hatte PW Platzhalter statt echter Passwörter - Bug 2: deploy_worker rief deploy_application auf Service-UUID auf (falsche API) - Bug 3: verify_worker_service akzeptierte nicht running:healthy Status - Fix: Echte Passwörter, update_service+restart statt deploy_application, Status-Check korrigiert
This commit is contained in:
+24
-21
@@ -65,11 +65,12 @@ services:
|
|||||||
entrypoint:
|
entrypoint:
|
||||||
- /app/worker.sh
|
- /app/worker.sh
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: 'postgresql+asyncpg://crm_worker:PW@crm-postgres:5432/crm_db'
|
DATABASE_URL: 'postgresql+asyncpg://crm_worker:4B6X2wlfbIx-PyaG8kGutsatdLbjdBUI@crm-postgres:5432/crm_db'
|
||||||
WORKER_DATABASE_URL: 'postgresql+asyncpg://crm_worker:PW@crm-postgres:5432/crm_db'
|
WORKER_DATABASE_URL: 'postgresql+asyncpg://crm_worker:4B6X2wlfbIx-PyaG8kGutsatdLbjdBUI@crm-postgres:5432/crm_db'
|
||||||
MIGRATION_DATABASE_URL: 'postgresql+asyncpg://crm_user:PW@crm-postgres:5432/crm_db'
|
MIGRATION_DATABASE_URL: 'postgresql+asyncpg://crm_user:4B6X2wlfbIx-PyaG8kGutsatdLbjdBUI@crm-postgres:5432/crm_db'
|
||||||
REDIS_URL: 'redis://default:PW@crm-redis:6379/0'
|
AUTH_DATABASE_URL: 'postgresql+asyncpg://crm_auth:4B6X2wlfbIx-PyaG8kGutsatdLbjdBUI@crm-postgres:5432/crm_db'
|
||||||
SECRET_KEY: 'PW'
|
REDIS_URL: 'redis://default:lAjCaTf3XFP5XSaPJ1HElgLAJhQQswLT@crm-redis:6379/0'
|
||||||
|
SECRET_KEY: 'vVdAnvyc-ob4myE5D1rAYn-SovzoBfQLP1z4wmWteTmFPV_lveCGIn2upNoiP590'
|
||||||
ENVIRONMENT: production
|
ENVIRONMENT: production
|
||||||
STORAGE_PATH: /data/storage
|
STORAGE_PATH: /data/storage
|
||||||
volumes:
|
volumes:
|
||||||
@@ -259,7 +260,14 @@ def deploy_api(client: CoolifyClient, skip_build: bool = False) -> StepResult:
|
|||||||
|
|
||||||
|
|
||||||
def deploy_worker(client: CoolifyClient, skip_build: bool = False) -> StepResult:
|
def deploy_worker(client: CoolifyClient, skip_build: bool = False) -> StepResult:
|
||||||
"""Deploy or restart the worker service via Coolify API."""
|
"""Deploy or restart the worker service via Coolify API.
|
||||||
|
|
||||||
|
The worker is a Coolify Service (not an Application), so we cannot use
|
||||||
|
the /deploy endpoint. Instead we:
|
||||||
|
1. Update the service's docker_compose_raw (applies new config)
|
||||||
|
2. Restart the service (pulls latest image and restarts container)
|
||||||
|
3. Wait for healthy status
|
||||||
|
"""
|
||||||
print(" Deploying worker service via Coolify API...")
|
print(" Deploying worker service via Coolify API...")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -270,24 +278,17 @@ def deploy_worker(client: CoolifyClient, skip_build: bool = False) -> StepResult
|
|||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
return _wait_service_healthy(client, WORKER_UUID, timeout=120)
|
return _wait_service_healthy(client, WORKER_UUID, timeout=120)
|
||||||
|
|
||||||
# Update the service with the latest docker_compose_raw
|
# Step 1: Update the service with the latest docker_compose_raw
|
||||||
print(" Updating worker service compose definition...")
|
print(" Updating worker service compose definition...")
|
||||||
client.update_service(WORKER_UUID, WORKER_COMPOSE_YAML)
|
client.update_service(WORKER_UUID, WORKER_COMPOSE_YAML)
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
# Trigger deploy via the deploy endpoint
|
# Step 2: Restart the service to pick up the latest image
|
||||||
print(" Triggering worker deployment...")
|
print(" Restarting worker service...")
|
||||||
result = client.deploy_application(WORKER_UUID)
|
client.restart_service(WORKER_UUID)
|
||||||
deploy_uuid = _extract_deploy_uuid(result)
|
time.sleep(5)
|
||||||
|
|
||||||
if deploy_uuid:
|
# Step 3: Wait for service to be healthy
|
||||||
print(f" Worker deploy queued: {deploy_uuid[:12]}")
|
|
||||||
dep_result = _wait_deployment(client, deploy_uuid, timeout=300)
|
|
||||||
if not dep_result.success:
|
|
||||||
return dep_result
|
|
||||||
else:
|
|
||||||
print(" No deployment UUID returned, checking service status directly...")
|
|
||||||
|
|
||||||
# Wait for service to be healthy
|
|
||||||
return _wait_service_healthy(client, WORKER_UUID, timeout=120)
|
return _wait_service_healthy(client, WORKER_UUID, timeout=120)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -433,7 +434,9 @@ def verify_worker_service(client: CoolifyClient) -> StepResult:
|
|||||||
try:
|
try:
|
||||||
svc = client.get_service(WORKER_UUID)
|
svc = client.get_service(WORKER_UUID)
|
||||||
status = svc.get("status", "unknown")
|
status = svc.get("status", "unknown")
|
||||||
if "running" in status.lower():
|
status_lower = status.lower()
|
||||||
|
# Accept 'running:healthy', 'running', 'healthy', or 'up'
|
||||||
|
if "running" in status_lower or "healthy" in status_lower or status_lower == "up":
|
||||||
return StepResult(True, f"Worker service: {status}", details={"status": status})
|
return StepResult(True, f"Worker service: {status}", details={"status": status})
|
||||||
return StepResult(False, f"Worker service not running: {status}", details={"status": status})
|
return StepResult(False, f"Worker service not running: {status}", details={"status": status})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user