File size: 1,401 Bytes
b641d3d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #!/usr/bin/env bash
set -euo pipefail
export APP_ROOT="${APP_ROOT:-/home/user/app}"
export MESH_ROOT="${MESH_ROOT:-/mesh}"
mkdir -p /tmp
redis-server --daemonize yes --logfile /tmp/redis.log --port 6379
until redis-cli ping >/dev/null; do sleep 0.2; done
rm -f /tmp/*.pid /tmp/*.log /tmp/worker_restart_count /tmp/consumer_stall_count /tmp/current_task
printf '0' > /tmp/worker_restart_count
printf '0' > /tmp/consumer_stall_count
cat > "${MESH_ROOT}/registry.json" <<'EOF'
{
"services": {
"auth": {"host": "localhost", "port": 3001, "protocol": "http"},
"redis": {"host": "localhost", "port": 6379, "protocol": "tcp"},
"worker": {"host": "localhost", "port": null, "protocol": "internal"}
}
}
EOF
: > /tmp/gateway.log
: > /tmp/auth.log
: > /tmp/worker.log
: > /tmp/job_gen.log
bun run "${APP_ROOT}/mesh/gateway/index.ts" >> /tmp/gateway.log &
echo $! > /tmp/gateway.pid
bun run "${APP_ROOT}/mesh/auth/index.ts" >> /tmp/auth.log &
echo $! > /tmp/auth.pid
bun run "${APP_ROOT}/mesh/worker/index.ts" >> /tmp/worker.log &
echo $! > /tmp/worker.pid
bun run "${APP_ROOT}/mesh/worker/job_generator.ts" >> /tmp/job_gen.log &
echo $! > /tmp/job_generator.pid
for _ in $(seq 1 45); do
if curl -sf http://localhost:3000/health >/dev/null && curl -sf http://localhost:3001/health >/dev/null; then
break
fi
sleep 1
done
exec uvicorn server.api:app --host 0.0.0.0 --port 8000
|