Something went wrong. Try again.
prefect server in zig
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130# Python prefect HA stack — apples-to-apples counterpart to compose.ha.yml.## Mirrors the zig HA shape: two webservers + one services container backed by# shared postgres + shared redis. Configured per prefect's official self-hosted# docs:# PREFECT_MESSAGING_BROKER=prefect_redis.messaging# PREFECT_MESSAGING_CACHE=prefect_redis.messaging# PREFECT_SERVER_EVENTS_CAUSAL_ORDERING=prefect_redis.ordering# PREFECT_SERVER_CONCURRENCY_LEASE_STORAGE=prefect_redis.lease_storage# PREFECT_SERVER_DOCKET_URL=redis://...## Host port allocation (offset by +100 vs compose.ha.yml so both stacks can# run concurrently for bench-compare):# postgres : 5433 → 5432# redis : 6380 → 6379# webapp-a : 4301 → 4200# webapp-b : 4302 → 4200## Usage:# docker compose -f compose.ha-python.yml up --build -d# curl http://localhost:4301/api/health# curl http://localhost:4302/api/health## Tear down (drops postgres volume):# docker compose -f compose.ha-python.yml down -v
name: prefect-py-ha
services: postgres: image: postgres:16-alpine environment: POSTGRES_USER: prefect POSTGRES_PASSWORD: prefect POSTGRES_DB: prefect ports: - "127.0.0.1:5433:5432" volumes: - prefect-pgdata-ha-python:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U prefect -d prefect"] interval: 2s timeout: 2s retries: 10
redis: image: redis:7-alpine command: ["redis-server", "--appendonly", "no"] ports: - "127.0.0.1:6380:6379" healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 1s timeout: 1s retries: 10
webapp-a: build: context: .. dockerfile: docker/Dockerfile.python-ha command: ["prefect", "server", "start", "--host", "0.0.0.0", "--port", "4200"] environment: &server-env PREFECT_SERVER_LOGGING_LEVEL: WARNING PREFECT_LOGGING_LEVEL: WARNING PREFECT_SERVER_DATABASE_CONNECTION_URL: "postgresql+asyncpg://prefect:prefect@postgres:5432/prefect" PREFECT_MESSAGING_BROKER: "prefect_redis.messaging" PREFECT_MESSAGING_CACHE: "prefect_redis.messaging" PREFECT_SERVER_EVENTS_CAUSAL_ORDERING: "prefect_redis.ordering" PREFECT_SERVER_CONCURRENCY_LEASE_STORAGE: "prefect_redis.lease_storage" PREFECT_SERVER_DOCKET_URL: "redis://redis:6379/1" PREFECT_REDIS_MESSAGING_HOST: "redis" PREFECT_REDIS_MESSAGING_PORT: "6379" PREFECT_REDIS_MESSAGING_DB: "0" ports: - "127.0.0.1:4301:4200" depends_on: postgres: condition: service_healthy redis: condition: service_healthy healthcheck: test: ["CMD-SHELL", "python -c 'import urllib.request, sys; sys.exit(0 if urllib.request.urlopen(\"http://localhost:4200/api/health\", timeout=2).status==200 else 1)'"] interval: 5s timeout: 4s retries: 12 start_period: 30s
webapp-b: build: context: .. dockerfile: docker/Dockerfile.python-ha command: ["prefect", "server", "start", "--host", "0.0.0.0", "--port", "4200"] environment: <<: *server-env ports: - "127.0.0.1:4302:4200" depends_on: postgres: condition: service_healthy redis: condition: service_healthy # Boot webapp-a first so its alembic migrations run before webapp-b # tries to start — avoids the race the zig stack also disclaims. webapp-a: condition: service_healthy healthcheck: test: ["CMD-SHELL", "python -c 'import urllib.request, sys; sys.exit(0 if urllib.request.urlopen(\"http://localhost:4200/api/health\", timeout=2).status==200 else 1)'"] interval: 5s timeout: 4s retries: 12 start_period: 30s
services: build: context: .. dockerfile: docker/Dockerfile.python-ha command: ["prefect", "server", "services", "start"] environment: <<: *server-env depends_on: postgres: condition: service_healthy redis: condition: service_healthy webapp-a: condition: service_healthy
volumes: prefect-pgdata-ha-python: