Refactored redis component to use a centralized postgres database with coordinator instead of descentralized sqlite shitty databases

This commit is contained in:
2026-06-30 18:07:47 -03:00
parent bae8712f3b
commit e81211c88e
10 changed files with 854 additions and 193 deletions
+22 -12
View File
@@ -2,21 +2,38 @@ services:
redis:
image: redis:7-alpine
command: ["redis-server", "--appendonly", "yes", "--bind", "0.0.0.0", "--protected-mode", "no"]
ports:
- "6379:6379"
volumes:
- camfinder-redis:/data
postgres:
image: postgres:16-alpine
environment:
POSTGRES_DB: camfinder
POSTGRES_USER: camfinder
POSTGRES_PASSWORD: camfinder
volumes:
- camfinder-postgres:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U camfinder -d camfinder"]
interval: 5s
timeout: 5s
retries: 10
start_period: 5s
coordinator:
build: .
command: ["redis-coordinator"]
environment:
REDIS_URL: redis://redis:6379/0
DATABASE_URL: postgres://camfinder:camfinder@postgres:5432/camfinder
RTSP_QUEUE_NAME: camfinder:rtsp:queue
RTSP_INPUT_CSV: /app/camfinder-open-rtsp.csv
RTSP_WORKER_COUNT: 2
RTSP_WORKER_COUNT: 8
depends_on:
- redis
redis:
condition: service_started
postgres:
condition: service_healthy
volumes:
- ./:/app:ro
@@ -27,7 +44,6 @@ services:
REDIS_URL: redis://redis:6379/0
RTSP_QUEUE_NAME: camfinder:rtsp:queue
RTSP_SNAPSHOT_DIR: /app/dump/feeds
RTSP_SQLITE_PATH: /app/dump/rtsp-results.sqlite
RTSP_CAPTURE_TIMEOUT_MS: 15000
depends_on:
- redis
@@ -42,7 +58,6 @@ services:
REDIS_URL: redis://redis:6379/0
RTSP_QUEUE_NAME: camfinder:rtsp:queue
RTSP_SNAPSHOT_DIR: /app/dump/feeds
RTSP_SQLITE_PATH: /app/dump/rtsp-results.sqlite
RTSP_CAPTURE_TIMEOUT_MS: 15000
depends_on:
- worker-1
@@ -56,7 +71,6 @@ services:
REDIS_URL: redis://redis:6379/0
RTSP_QUEUE_NAME: camfinder:rtsp:queue
RTSP_SNAPSHOT_DIR: /app/dump/feeds
RTSP_SQLITE_PATH: /app/dump/rtsp-results.sqlite
RTSP_CAPTURE_TIMEOUT_MS: 15000
depends_on:
- worker-2
@@ -70,7 +84,6 @@ services:
REDIS_URL: redis://redis:6379/0
RTSP_QUEUE_NAME: camfinder:rtsp:queue
RTSP_SNAPSHOT_DIR: /app/dump/feeds
RTSP_SQLITE_PATH: /app/dump/rtsp-results.sqlite
RTSP_CAPTURE_TIMEOUT_MS: 15000
depends_on:
- worker-3
@@ -84,7 +97,6 @@ services:
REDIS_URL: redis://redis:6379/0
RTSP_QUEUE_NAME: camfinder:rtsp:queue
RTSP_SNAPSHOT_DIR: /app/dump/feeds
RTSP_SQLITE_PATH: /app/dump/rtsp-results.sqlite
RTSP_CAPTURE_TIMEOUT_MS: 15000
depends_on:
- worker-4
@@ -98,7 +110,6 @@ services:
REDIS_URL: redis://redis:6379/0
RTSP_QUEUE_NAME: camfinder:rtsp:queue
RTSP_SNAPSHOT_DIR: /app/dump/feeds
RTSP_SQLITE_PATH: /app/dump/rtsp-results.sqlite
RTSP_CAPTURE_TIMEOUT_MS: 15000
depends_on:
- worker-5
@@ -112,7 +123,6 @@ services:
REDIS_URL: redis://redis:6379/0
RTSP_QUEUE_NAME: camfinder:rtsp:queue
RTSP_SNAPSHOT_DIR: /app/dump/feeds
RTSP_SQLITE_PATH: /app/dump/rtsp-results.sqlite
RTSP_CAPTURE_TIMEOUT_MS: 15000
depends_on:
- worker-6
@@ -126,7 +136,6 @@ services:
REDIS_URL: redis://redis:6379/0
RTSP_QUEUE_NAME: camfinder:rtsp:queue
RTSP_SNAPSHOT_DIR: /app/dump/feeds
RTSP_SQLITE_PATH: /app/dump/rtsp-results.sqlite
RTSP_CAPTURE_TIMEOUT_MS: 15000
depends_on:
- worker-7
@@ -134,3 +143,4 @@ services:
- ./dump:/app/dump
volumes:
camfinder-redis:
camfinder-postgres: