prefect server in zig
1default:
2 @just --list
3
4# build the server
5build:
6 zig build
7
8# build optimized release
9build-release:
10 zig build -Doptimize=ReleaseFast
11
12# run dev server (sqlite, memory broker, debug logging)
13dev: build
14 rm -f prefect.db
15 PREFECT_SERVER_LOGGING_LEVEL=DEBUG ./zig-out/bin/prefect-server
16
17# run API test suite against local server
18test:
19 PREFECT_API_URL=http://localhost:4200/api ./scripts/test-api-sequence
20
21# run .serve() integration test
22test-serve:
23 PREFECT_API_URL=http://localhost:4200/api ./scripts/test-serve
24
25# broker backend tests (memory + redis)
26test-broker backend="all":
27 #!/usr/bin/env bash
28 set -euo pipefail
29 if [ "{{backend}}" = "redis" ] || [ "{{backend}}" = "all" ]; then
30 docker compose up -d redis
31 sleep 1
32 fi
33 ./scripts/test-broker-backends {{backend}}
34 if [ "{{backend}}" = "redis" ] || [ "{{backend}}" = "all" ]; then
35 docker compose down redis
36 fi
37
38# database backend tests (sqlite + postgres)
39test-db backend="all":
40 #!/usr/bin/env bash
41 set -euo pipefail
42 if [ "{{backend}}" = "postgres" ] || [ "{{backend}}" = "all" ]; then
43 docker compose up -d postgres
44 sleep 2
45 fi
46 ./scripts/test-db-backends {{backend}}
47 if [ "{{backend}}" = "postgres" ] || [ "{{backend}}" = "all" ]; then
48 docker compose down postgres
49 fi
50
51# run high-level prefect client tests (requires running server)
52test-client:
53 PREFECT_API_URL=http://localhost:4200/api ./scripts/test-flow
54 PREFECT_API_URL=http://localhost:4200/api ./scripts/test-blocks
55
56# run worker integration tests (scheduler + worker execution)
57test-worker:
58 PREFECT_API_URL=http://localhost:4200/api ./scripts/test-worker
59
60# run full test matrix (all db × broker combinations)
61test-matrix:
62 ./scripts/test-matrix
63
64# run quick test (sqlite + memory only)
65test-quick:
66 ./scripts/test-matrix --quick
67
68# run all tests (legacy - prefer test-matrix)
69test-all: test test-serve test-client test-broker test-db
70
71# start dev services (redis + postgres)
72services-up:
73 docker compose up -d redis postgres
74
75# stop dev services
76services-down:
77 docker compose down
78
79# build and run server in docker
80docker-build:
81 docker compose build server
82
83# run server in docker (sqlite + memory)
84docker-run: docker-build
85 docker compose up server
86
87# run integration tests in docker
88docker-test:
89 docker compose up --build -d server
90 docker compose run --rm test
91 docker compose down
92
93# run server with postgres + redis in docker
94docker-full:
95 PREFECT_DATABASE_BACKEND=postgres \
96 PREFECT_DATABASE_URL="postgresql://prefect:prefect@postgres:5432/prefect" \
97 PREFECT_BROKER_BACKEND=redis \
98 docker compose up --build
99
100# run integration tests with postgres + redis
101docker-full-test:
102 PREFECT_DATABASE_BACKEND=postgres \
103 PREFECT_DATABASE_URL="postgresql://prefect:prefect@postgres:5432/prefect" \
104 PREFECT_BROKER_BACKEND=redis \
105 docker compose up --build -d server
106 docker compose run --rm test
107 docker compose down
108
109# performance benchmark (zig server)
110bench:
111 ./scripts/benchmark --server zig
112
113# performance benchmark comparison (zig vs python)
114bench-compare:
115 ./scripts/benchmark --compare
116
117# performance benchmark matrix (all db × broker combinations)
118bench-matrix:
119 ./scripts/benchmark --matrix
120
121# publish docker image to atcr.io
122docker-publish tag="latest":
123 docker build -t prefect-server:{{tag}} .
124 docker tag prefect-server:{{tag}} atcr.io/zzstoatzz.io/prefect-server:{{tag}}
125 docker push atcr.io/zzstoatzz.io/prefect-server:{{tag}}
126
127# clean build artifacts
128clean:
129 rm -rf zig-out .zig-cache prefect.db
130
131# --- kubernetes ---
132
133# deploy to kubernetes
134k8s-deploy:
135 kubectl apply -k k8s/
136
137# check kubernetes status
138k8s-status:
139 kubectl -n prefect get pods,svc
140
141# port-forward to access locally
142k8s-forward:
143 kubectl -n prefect port-forward svc/prefect-server 4200:4200
144
145# scale API servers
146k8s-scale replicas="3":
147 kubectl -n prefect scale deployment/prefect-api --replicas={{replicas}}
148
149# view logs
150k8s-logs component="api":
151 kubectl -n prefect logs -l app.kubernetes.io/component={{component}} -f
152
153# delete kubernetes deployment
154k8s-delete:
155 kubectl delete -k k8s/