chatai/supabase/kong/wrapper.sh

36 lines
1.0 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -euo pipefail
# --- 信号处理 ---
cleanup() {
echo "[kong] Caught termination signal, shutting down..."
exit 0
}
trap cleanup SIGINT SIGTERM SIGQUIT
# --- 环境变量配置 ---
export KONG_DATABASE="off"
export KONG_PG_HOST="127.0.0.1"
export KONG_PG_PORT="5432"
export KONG_PG_USER="supabase_admin"
export KONG_PG_PASSWORD="postgres"
export KONG_PG_DATABASE="postgres"
export KONG_LOG_LEVEL="debug"
export KONG_PROXY_ACCESS_LOG="/dev/stdout"
export KONG_ADMIN_ACCESS_LOG="/dev/stdout"
export KONG_PROXY_ERROR_LOG="/dev/stderr"
export KONG_ADMIN_ERROR_LOG="/dev/stderr"
export KONG_PREFIX="/usr/local/kong"
# --- 等待 postgrest (通过 Kong proxy) 可访问 ---
echo "[kong] Waiting for PostgREST to be reachable via Kong..."
until curl -s http://localhost:5000/rest/v1/ >/dev/null 2>&1; do
echo "[kong] Still waiting for PostgREST..."
sleep 1
done
echo "[kong] PostgREST is reachable. Starting Kong..."
# --- 启动 Kong使用 docker-entrypoint.sh + docker-start 模式) ---
exec /supabase/kong/docker-entrypoint.sh kong docker-start