From 0e9705f5c59074435a65b7e4ce8d86bc8fa6c4d8 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 17 May 2025 22:37:48 +0800 Subject: [PATCH] . --- Dockerfile | 1 + supabase/kong/wrapper.sh | 28 +++++++++++++++++++++++----- supabase/postgres/supervisord.conf | 13 ------------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6ea3e1b..f290772 100644 --- a/Dockerfile +++ b/Dockerfile @@ -384,3 +384,4 @@ RUN set -ex; \ fi COPY --chmod=0755 docker-kong_v2.8.1/ubuntu/docker-entrypoint.sh /supabase/kong/docker-entrypoint.sh + diff --git a/supabase/kong/wrapper.sh b/supabase/kong/wrapper.sh index 50d433b..3162430 100644 --- a/supabase/kong/wrapper.sh +++ b/supabase/kong/wrapper.sh @@ -1,17 +1,35 @@ #!/bin/bash set -euo pipefail -# 捕获 SIGINT / SIGTERM / SIGQUIT 信号以优雅退出 +# --- 信号处理 --- cleanup() { - echo "[gotrue] Caught termination signal, shutting down..." + echo "[kong] Caught termination signal, shutting down..." exit 0 } +trap cleanup SIGINT SIGTERM SIGQUIT -trap 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 "Waiting for postgrest (via Kong)..." + echo "[kong] Still waiting for PostgREST..." sleep 1 done +echo "[kong] PostgREST is reachable. Starting Kong..." -exec kong start -c /supabase/kong/kong.conf +# --- 启动 Kong(使用 docker-entrypoint.sh + docker-start 模式) --- +exec /supabase/kong/docker-entrypoint.sh kong docker-start diff --git a/supabase/postgres/supervisord.conf b/supabase/postgres/supervisord.conf index 191409f..cdc345e 100644 --- a/supabase/postgres/supervisord.conf +++ b/supabase/postgres/supervisord.conf @@ -50,19 +50,6 @@ user=kong autorestart=true stdout_logfile=/var/log/kong.out.log stderr_logfile=/var/log/kong.err.log -environment= - KONG_DATABASE="postgres", - KONG_PG_HOST="127.0.0.1", - KONG_PG_PORT="5432", - KONG_PG_USER="supabase_admin", - KONG_PG_PASSWORD="postgres", - KONG_PG_DATABASE="postgres", - KONG_LOG_LEVEL="info", - KONG_PROXY_ACCESS_LOG="/dev/stdout", - KONG_ADMIN_ACCESS_LOG="/dev/stdout", - KONG_PROXY_ERROR_LOG="/dev/stderr", - KONG_ADMIN_ERROR_LOG="/dev/stderr", - KONG_PREFIX="/usr/local/kong"