Hotfix: cleanup legacy v2 containers + auto-expire ringing calls (v2.2.44)

This commit is contained in:
Christian 2026-03-04 00:33:12 +01:00
parent 803b45fab4
commit 701cc63375
4 changed files with 50 additions and 1 deletions

17
RELEASE_NOTES_v2.2.44.md Normal file
View File

@ -0,0 +1,17 @@
# Release Notes v2.2.44
Dato: 4. marts 2026
## Fixes
- `updateto.sh` rydder nu automatisk legacy containere (`bmc-hub-api-v2`, `bmc-hub-postgres-v2`) før deploy.
- Forebygger port-lock konflikter på især Postgres host-port (`5433`) under compose opstart.
- Mission Control: automatisk timeout på hængende `ringing` opkald, så de ikke bliver stående i Incoming Calls.
## Ændrede filer
- `updateto.sh`
- `app/dashboard/backend/mission_service.py`
- `VERSION`
## Drift
- Deploy: `./updateto.sh v2.2.44`
- Verificér: `curl http://localhost:8001/health`

View File

@ -1 +1 @@
2.2.43
2.2.44

View File

@ -5,6 +5,30 @@ from app.core.database import execute_query, execute_query_single
class MissionService:
@staticmethod
def get_ring_timeout_seconds() -> int:
raw = MissionService.get_setting_value("mission_call_ring_timeout_seconds", "180") or "180"
try:
value = int(raw)
except (TypeError, ValueError):
value = 180
return max(30, min(value, 3600))
@staticmethod
def expire_stale_ringing_calls() -> None:
timeout_seconds = MissionService.get_ring_timeout_seconds()
execute_query(
"""
UPDATE mission_call_state
SET state = 'hangup',
ended_at = COALESCE(ended_at, NOW()),
updated_at = NOW()
WHERE state = 'ringing'
AND started_at < (NOW() - make_interval(secs => %s))
""",
(timeout_seconds,),
)
@staticmethod
def get_setting_value(key: str, default: Optional[str] = None) -> Optional[str]:
row = execute_query_single("SELECT value FROM settings WHERE key = %s", (key,))
@ -144,6 +168,7 @@ class MissionService:
@staticmethod
def get_active_calls() -> list[Dict[str, Any]]:
MissionService.expire_stale_ringing_calls()
rows = execute_query(
"""
SELECT call_id, queue_name, caller_number, contact_name, company_name, customer_tag, state, started_at, answered_at, ended_at, updated_at

View File

@ -74,6 +74,13 @@ fi
echo "✅ .env opdateret"
# Cleanup legacy container names from older compose variants (can lock host ports)
echo ""
echo "🧹 Rydder legacy containere (v2-navne)..."
podman update --restart=no bmc-hub-api-v2 bmc-hub-postgres-v2 >/dev/null 2>&1 || true
podman stop bmc-hub-api-v2 bmc-hub-postgres-v2 >/dev/null 2>&1 || true
podman rm -f bmc-hub-api-v2 bmc-hub-postgres-v2 >/dev/null 2>&1 || true
# Guard against host port conflicts before attempting startup
POSTGRES_BIND_ADDR="${POSTGRES_BIND_ADDR:-127.0.0.1}"
POSTGRES_PORT="${POSTGRES_PORT:-5432}"