fix: wait for stunnel before starting
This commit is contained in:
parent
0daa20a0f2
commit
1a9eaf13df
@ -31,7 +31,7 @@ server:
|
|||||||
|
|
||||||
store:
|
store:
|
||||||
driver: "postgres"
|
driver: "postgres"
|
||||||
dsn: "postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?sslmode=disable"
|
dsn: "postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?sslmode=disable"
|
||||||
maxOpenConns: 30
|
maxOpenConns: 30
|
||||||
maxIdleConns: 10
|
maxIdleConns: 10
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
# --- 主应用容器 ---
|
# --- 主应用容器 ---
|
||||||
- name: accounts-api
|
- name: accounts-api
|
||||||
image: asia-northeast1-docker.pkg.dev/xzerolab-480008/cloud-run-source-deploy/accounts.svc.plus/accounts-svc-plus:latest
|
image: asia-northeast1-docker.pkg.dev/xzerolab-480008/cloud-run-source-deploy/accounts.svc.plus/accounts-svc-plus:217c617b25328b3529ba2ec983d5a4f71849cf30
|
||||||
ports:
|
ports:
|
||||||
- name: http1
|
- name: http1
|
||||||
containerPort: 8080
|
containerPort: 8080
|
||||||
@ -32,7 +32,12 @@ spec:
|
|||||||
- name: DB_PASSWORD
|
- name: DB_PASSWORD
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: admin_password
|
name: postgres-password
|
||||||
|
key: latest
|
||||||
|
- name: POSTGRES_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: postgres-password
|
||||||
key: latest
|
key: latest
|
||||||
- name: DB_HOST
|
- name: DB_HOST
|
||||||
value: "127.0.0.1"
|
value: "127.0.0.1"
|
||||||
@ -40,6 +45,8 @@ spec:
|
|||||||
value: "15432"
|
value: "15432"
|
||||||
- name: DB_USER
|
- name: DB_USER
|
||||||
value: postgres
|
value: postgres
|
||||||
|
- name: POSTGRES_USER
|
||||||
|
value: postgres
|
||||||
- name: DB_NAME
|
- name: DB_NAME
|
||||||
value: postgres
|
value: postgres
|
||||||
resources:
|
resources:
|
||||||
|
|||||||
@ -31,4 +31,21 @@ if [ -n "${PORT:-}" ]; then
|
|||||||
CONFIG_FILE="${tmp_cfg}"
|
CONFIG_FILE="${tmp_cfg}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_HOST:-}" ] && [ -n "${DB_PORT:-}" ]; then
|
||||||
|
if [ "${DB_HOST}" = "127.0.0.1" ] || [ "${DB_HOST}" = "localhost" ]; then
|
||||||
|
if command -v nc >/dev/null; then
|
||||||
|
wait_seconds="${STUNNEL_WAIT_SECONDS:-30}"
|
||||||
|
i=0
|
||||||
|
while ! nc -z "${DB_HOST}" "${DB_PORT}" >/dev/null 2>&1; do
|
||||||
|
i=$((i + 1))
|
||||||
|
if [ "${i}" -ge "${wait_seconds}" ]; then
|
||||||
|
echo "stunnel not ready after ${wait_seconds}s on ${DB_HOST}:${DB_PORT}" >&2
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
exec /usr/local/bin/account --config "${CONFIG_FILE}" "$@"
|
exec /usr/local/bin/account --config "${CONFIG_FILE}" "$@"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user