Spaces:
Sleeping
Sleeping
Update start.sh
Browse files34 unmodified lines35363738394041424344454647484950515253545556575859606111 unmodified lines7374757677787980818283848586878889909192939495969734 unmodified linesexport CONVEX_LOCAL_STORAGE_DIR="/data/v4/convex_local_storage"mkdir -p "$CONVEX_LOCAL_STORAGE_DIR"# 8. THE ROOT CAUSE FIX:# read_credentials.sh sources INSTANCE_NAME and INSTANCE_SECRET in this priority:# 1. Env var (what we set here)# 2. File in CREDENTIALS_DIR# 3. Random/default## Previously INSTANCE_NAME was defaulting to "convex-self-hosted" but the backend# was started with --instance-name "leadshello-agent-ai" — mismatch = BadAdminKey.## We also point CREDENTIALS_DIR to persistent storage so credentials survive reboots.export INSTANCE_NAME="leadshello-agent-ai"export INSTANCE_SECRET="${CONVEX_INSTANCE_SECRET:-deadbeefcafebabe0123456789abcdeffedcba9876543210deadbeefcafebabe}"export CREDENTIALS_DIR="/data/v4/credentials"export DATA_DIR="/data/v4"mkdir -p "$CREDENTIALS_DIR"# Persist the credentials to disk so they survive across reboots even without env varsecho "$INSTANCE_NAME" > "$CREDENTIALS_DIR/instance_name"echo "$INSTANCE_SECRET" > "$CREDENTIALS_DIR/instance_secret"# 9. Start the live databaseecho "Starting Convex Backend on Permanent Storage..."./convex-local-backend \11 unmodified linessleep 1done# 11. Generate admin key using the now-correct INSTANCE_NAME and INSTANCE_SECRETADMIN_KEY=$(./generate_admin_key.sh 2>/dev/null | grep "convex-self-hosted" | tr -d '[:space:]')echo "=========================================================="echo "YOUR TRUE FOREVER ADMIN KEY IS:"echo "$ADMIN_KEY"echo "=========================================================="# 12. Verify the key directly against the backend (bypasses nginx entirely)echo "Verifying key against backend on port 3210..."VERIFY=$(curl -s -X POST http://127.0.0.1:3210/api/get_config_hashes \-H "Content-Type: application/json" \-d "{\"adminKey\": \"$ADMIN_KEY\"}")if echo "$VERIFY" | grep -q "BadAdminKey"; thenecho "STATUS: KEY STILL REJECTED — check instance name/secret match"elseecho "STATUS: KEY ACCEPTED — backend confirmed key is valid!"fiecho "Verification response: $VERIFY"# 13. Keep the container alive forevertail -f /dev/null34 unmodified lines353637383940414243444546474849505152535411 unmodified lines6667686970717273747576777879808182838485868788899091929394959634 unmodified linesexport CONVEX_LOCAL_STORAGE_DIR="/data/v4/convex_local_storage"mkdir -p "$CONVEX_LOCAL_STORAGE_DIR"# 8. Set credentials — INSTANCE_NAME must match --instance-name passed to backend# CREDENTIALS_DIR points to persistent storage so credentials survive rebootsexport INSTANCE_NAME="leadshello-agent-ai"export INSTANCE_SECRET="${CONVEX_INSTANCE_SECRET:-deadbeefcafebabe0123456789abcdeffedcba9876543210deadbeefcafebabe}"export CREDENTIALS_DIR="/data/v4/credentials"export DATA_DIR="/data/v4"mkdir -p "$CREDENTIALS_DIR"echo "$INSTANCE_NAME" > "$CREDENTIALS_DIR/instance_name"echo "$INSTANCE_SECRET" > "$CREDENTIALS_DIR/instance_secret"echo "Using INSTANCE_NAME: $INSTANCE_NAME"echo "Using INSTANCE_SECRET: $INSTANCE_SECRET"echo "Using CREDENTIALS_DIR: $CREDENTIALS_DIR"# 9. Start the live databaseecho "Starting Convex Backend on Permanent Storage..."./convex-local-backend \11 unmodified linessleep 1done# 11. Run generate_admin_key.sh with ALL output visible (no suppression)# so we can see exactly what it produces or what error it throwsecho "=========================================================="echo "RAW OUTPUT OF generate_admin_key.sh:"./generate_admin_key.shecho "(end of raw output)"echo "=========================================================="# 12. Capture just the key and verify it directlyADMIN_KEY=$(./generate_admin_key.sh 2>&1 | grep "convex-self-hosted" | tr -d '[:space:]')echo "Extracted key: $ADMIN_KEY"if [ -z "$ADMIN_KEY" ]; thenecho "ERROR: Could not extract admin key from generate_admin_key.sh output above"elseVERIFY=$(curl -s -X POST http://127.0.0.1:3210/api/get_config_hashes \-H "Content-Type: application/json" \-d "{\"adminKey\": \"$ADMIN_KEY\"}")if echo "$VERIFY" | grep -q "BadAdminKey"; thenecho "STATUS: KEY REJECTED by backend"elseecho "STATUS: KEY ACCEPTED — this is your working deploy key!"fiecho "Verification response: $VERIFY"fi# 13. Keep the container alive forevertail -f /dev/null
start.sh+27-28