Add health check
This commit is contained in:
parent
9c2e5ca79c
commit
8d008df1ae
3 changed files with 23 additions and 4 deletions
|
@ -6,7 +6,7 @@ ARG TW_BIN=./bin/tailwindcss
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . /app
|
COPY . /app
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends build-essential curl libev-dev
|
RUN apt-get update && apt-get install -y --no-install-recommends build-essential curl wget libev-dev
|
||||||
|
|
||||||
RUN mkdir -p ./bin \
|
RUN mkdir -p ./bin \
|
||||||
&& curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/download/v${TW_VERSION}/tailwindcss-linux-x64 \
|
&& curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/download/v${TW_VERSION}/tailwindcss-linux-x64 \
|
||||||
|
|
|
@ -1,6 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
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..10}; 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
|
if [[ -n "$CLOUDFLARE_ZONE_ID" && -n "$CLOUDFLARE_API_KEY" ]]; then
|
||||||
echo "Purging Cloudflare cache..."
|
echo "Purging Cloudflare cache..."
|
||||||
curl -s -X POST "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_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."
|
echo "Cloudflare credentials not provided. Skipping cache purge."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting server..."
|
wait $SERVER_PID
|
||||||
exec .qlot/bin/clackup --system hp --server woo --address 0.0.0.0 --port 3000 src/app.lisp
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
(defpackage #:hp/routes/index
|
(defpackage #:hp/routes/index
|
||||||
(:use #:cl
|
(:use #:cl
|
||||||
#:hsx)
|
#:hsx)
|
||||||
(:export #:handle-get))
|
(:export #:handle-get
|
||||||
|
#:handle-head))
|
||||||
(in-package #:hp/routes/index)
|
(in-package #:hp/routes/index)
|
||||||
|
|
||||||
(defparameter *links*
|
(defparameter *links*
|
||||||
|
@ -30,3 +31,7 @@
|
||||||
(declare (ignore params))
|
(declare (ignore params))
|
||||||
(list :body (~page)
|
(list :body (~page)
|
||||||
:cache :static))
|
:cache :static))
|
||||||
|
|
||||||
|
; for health check
|
||||||
|
(defun handle-head (params)
|
||||||
|
(declare (ignore params)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue