Add health check

This commit is contained in:
Akira Tempaku 2025-05-01 12:46:15 +09:00
parent 9c2e5ca79c
commit 06cc61f247
Signed by: paku
GPG key ID: 5B4E8402BCC50607
3 changed files with 23 additions and 4 deletions

View file

@ -1,6 +1,21 @@
#!/bin/bash
set -e
echo "Starting server..."
.qlot/bin/clackup --system hp --server woo --address 0.0.0.0 --port 3000 src/app.lisp &
SERVER_PID=$!
echo "Waiting for server to be ready..."
for i in {1..20}; do
if curl -s -o /dev/null -w "%{http_code}" -I http://0.0.0.0:3000 | grep -q "200"; then
echo "Server is up."
break
fi
echo "Server not ready yet... retrying ($i)"
sleep 5
done
if [[ -n "$CLOUDFLARE_ZONE_ID" && -n "$CLOUDFLARE_API_KEY" ]]; then
echo "Purging Cloudflare cache..."
curl -s -X POST "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache" \
@ -11,5 +26,4 @@ else
echo "Cloudflare credentials not provided. Skipping cache purge."
fi
echo "Starting server..."
exec .qlot/bin/clackup --system hp --server woo --address 0.0.0.0 --port 3000 src/app.lisp
wait $SERVER_PID