optz: Goal orchestrator
This commit is contained in:
@@ -40,14 +40,26 @@ start_auth_bridge() {
|
||||
openssl rand -hex 32 > "$AUTH_BRIDGE_TOKEN_FILE"
|
||||
chmod 600 "$AUTH_BRIDGE_TOKEN_FILE"
|
||||
fi
|
||||
if [[ -f "$AUTH_BRIDGE_PID_FILE" ]] && kill -0 "$(cat "$AUTH_BRIDGE_PID_FILE")" 2>/dev/null; then
|
||||
if curl -fsS -m 2 "http://127.0.0.1:20130/healthz" >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
if [[ -f "$AUTH_BRIDGE_PID_FILE" ]]; then
|
||||
local existing_pid
|
||||
existing_pid="$(cat "$AUTH_BRIDGE_PID_FILE")"
|
||||
# A PID can be stale or reused by an unrelated process. Health is the
|
||||
# authoritative signal; clean the stale state before starting the bridge.
|
||||
kill "$existing_pid" 2>/dev/null || true
|
||||
rm -f "$AUTH_BRIDGE_PID_FILE"
|
||||
fi
|
||||
[[ -f "$AUTH_BRIDGE" ]] || { echo "CASAN_AUTH_BRIDGE_MISSING" >&2; return 1; }
|
||||
nohup python3 "$AUTH_BRIDGE" --bind 0.0.0.0 --port 20130 --token-file "$AUTH_BRIDGE_TOKEN_FILE" --audit-log "$AUTH_BRIDGE_AUDIT" > "$AUTH_BRIDGE_LOG" 2>&1 &
|
||||
echo "$!" > "$AUTH_BRIDGE_PID_FILE"
|
||||
chmod 600 "$AUTH_BRIDGE_PID_FILE" "$AUTH_BRIDGE_LOG" "$AUTH_BRIDGE_AUDIT" 2>/dev/null || true
|
||||
wait_url "http://127.0.0.1:20130/healthz"
|
||||
if ! wait_url "http://127.0.0.1:20130/healthz"; then
|
||||
kill "$(cat "$AUTH_BRIDGE_PID_FILE")" 2>/dev/null || true
|
||||
rm -f "$AUTH_BRIDGE_PID_FILE"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
stop_auth_bridge() {
|
||||
@@ -112,8 +124,8 @@ case "$CMD" in
|
||||
bash "$INFRA" status
|
||||
echo "=== control panel ==="
|
||||
cp_compose ps
|
||||
if [[ -f "$AUTH_BRIDGE_PID_FILE" ]] && kill -0 "$(cat "$AUTH_BRIDGE_PID_FILE")" 2>/dev/null; then
|
||||
echo "provider_auth_bridge=running pid=$(cat "$AUTH_BRIDGE_PID_FILE")"
|
||||
if curl -fsS -m 2 "http://127.0.0.1:20130/healthz" >/dev/null 2>&1; then
|
||||
echo "provider_auth_bridge=running"
|
||||
else
|
||||
echo "provider_auth_bridge=stopped"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user