mirror of https://github.com/kortix-ai/suna.git
oof slmost there
This commit is contained in:
parent
0fc3c4a573
commit
d181786438
|
@ -0,0 +1,25 @@
|
|||
# LLM API Keys - Replace with your actual keys
|
||||
ANTHROPIC_API_KEY=your-anthropic-api-key
|
||||
OPENAI_API_KEY=your-openai-api-key
|
||||
MODEL_TO_USE=anthropic/claude-3-7-sonnet-latest
|
||||
|
||||
# Optional API Keys - Replace with your actual keys if needed
|
||||
TAVILY_API_KEY=your-tavily-api-key
|
||||
RAPID_API_KEY=your-rapid-api-key
|
||||
|
||||
EXA_API_KEY=your-exa-api-key
|
||||
|
||||
# URLs and Public Configuration
|
||||
NEXT_PUBLIC_URL=http://localhost:3000
|
||||
NEXT_PUBLIC_BACKEND_URL=http://localhost:8000/api
|
||||
|
||||
# Redis Configuration (local development)
|
||||
REDIS_HOST=localhost
|
||||
REDIS_PORT=6379
|
||||
REDIS_PASSWORD=
|
||||
REDIS_SSL=False
|
||||
|
||||
# Daytona Configuration
|
||||
DAYTONA_API_KEY=your-daytona-api-key
|
||||
DAYTONA_SERVER_URL=https://app.daytona.io/api
|
||||
DAYTONA_TARGET=us
|
|
@ -0,0 +1,40 @@
|
|||
_format_version: "2.1"
|
||||
|
||||
_transform: true
|
||||
|
||||
services:
|
||||
- name: postgrest
|
||||
url: http://supabase-db:5432
|
||||
routes:
|
||||
- name: postgrest-route
|
||||
paths:
|
||||
- /rest/v1
|
||||
plugins:
|
||||
- name: cors
|
||||
- name: key-auth
|
||||
config:
|
||||
hide_credentials: true
|
||||
|
||||
- name: auth
|
||||
url: http://supabase-db:5432
|
||||
routes:
|
||||
- name: auth-route
|
||||
paths:
|
||||
- /auth/v1
|
||||
plugins:
|
||||
- name: cors
|
||||
- name: key-auth
|
||||
config:
|
||||
hide_credentials: true
|
||||
|
||||
- name: storage
|
||||
url: http://supabase-db:5432
|
||||
routes:
|
||||
- name: storage-route
|
||||
paths:
|
||||
- /storage/v1
|
||||
plugins:
|
||||
- name: cors
|
||||
- name: key-auth
|
||||
config:
|
||||
hide_credentials: true
|
|
@ -1,7 +1,21 @@
|
|||
import { createBrowserClient } from "@supabase/ssr";
|
||||
|
||||
export const createClient = () =>
|
||||
createBrowserClient(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
||||
export const createClient = () => {
|
||||
// Get URL and key from environment variables
|
||||
let supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!;
|
||||
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!;
|
||||
|
||||
// Ensure the URL is in the proper format with http/https protocol
|
||||
if (supabaseUrl && !supabaseUrl.startsWith('http')) {
|
||||
// If it's just a hostname without protocol, add http://
|
||||
supabaseUrl = `http://${supabaseUrl}`;
|
||||
}
|
||||
|
||||
console.log('Supabase URL:', supabaseUrl);
|
||||
console.log('Supabase Anon Key:', supabaseAnonKey);
|
||||
|
||||
return createBrowserClient(
|
||||
supabaseUrl,
|
||||
supabaseAnonKey,
|
||||
);
|
||||
};
|
||||
|
|
|
@ -4,10 +4,21 @@ import { cookies } from "next/headers";
|
|||
|
||||
export const createClient = async () => {
|
||||
const cookieStore = await cookies();
|
||||
let supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!;
|
||||
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!;
|
||||
|
||||
// Ensure the URL is in the proper format with http/https protocol
|
||||
if (supabaseUrl && !supabaseUrl.startsWith('http')) {
|
||||
// If it's just a hostname without protocol, add http://
|
||||
supabaseUrl = `http://${supabaseUrl}`;
|
||||
}
|
||||
|
||||
console.log('[SERVER] Supabase URL:', supabaseUrl);
|
||||
console.log('[SERVER] Supabase Anon Key:', supabaseAnonKey);
|
||||
|
||||
return createServerClient(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
||||
supabaseUrl,
|
||||
supabaseAnonKey,
|
||||
{
|
||||
cookies: {
|
||||
getAll() {
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Print colored output
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${RED}Cleaning up all services...${NC}"
|
||||
|
||||
# Stop all running background processes from previous runs
|
||||
echo -e "${BLUE}Stopping background processes...${NC}"
|
||||
pkill -f "uvicorn api:app"
|
||||
pkill -f "npm run dev"
|
||||
|
||||
# Stop Redis container if running
|
||||
echo -e "${BLUE}Stopping Redis container...${NC}"
|
||||
docker stop agentpress-redis 2>/dev/null || true
|
||||
docker rm agentpress-redis 2>/dev/null || true
|
||||
|
||||
# Stop Supabase
|
||||
echo -e "${BLUE}Stopping Supabase...${NC}"
|
||||
cd backend/supabase
|
||||
supabase stop 2>/dev/null || true
|
||||
cd ../..
|
||||
|
||||
echo -e "${GREEN}Cleanup complete. You can now start the services again.${NC}"
|
|
@ -0,0 +1,74 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Create necessary directories
|
||||
mkdir -p docker
|
||||
|
||||
# Fix any spacing issues in the JWT tokens using macOS compatible sed
|
||||
if [ -f ".env" ]; then
|
||||
sed -i '' 's/ey AgC/eyAgC/g' .env
|
||||
fi
|
||||
|
||||
if [ -f "docker-compose.yml" ]; then
|
||||
sed -i '' 's/ey AgC/eyAgC/g' docker-compose.yml
|
||||
fi
|
||||
|
||||
# Create a symbolic link for .env.local in frontend
|
||||
if [ -f ".env" ]; then
|
||||
cp .env frontend/.env.local
|
||||
fi
|
||||
|
||||
# Create a symbolic link for Kong configuration if it doesn't exist
|
||||
if [ ! -f "./backend/supabase/kong.yml" ]; then
|
||||
echo "Creating Kong configuration file"
|
||||
mkdir -p ./backend/supabase
|
||||
cat > ./backend/supabase/kong.yml << EOL
|
||||
_format_version: "2.1"
|
||||
|
||||
_transform: true
|
||||
|
||||
services:
|
||||
- name: postgrest
|
||||
url: http://supabase-db:5432
|
||||
routes:
|
||||
- name: postgrest-route
|
||||
paths:
|
||||
- /rest/v1
|
||||
plugins:
|
||||
- name: cors
|
||||
- name: key-auth
|
||||
config:
|
||||
hide_credentials: true
|
||||
|
||||
- name: auth
|
||||
url: http://supabase-db:5432
|
||||
routes:
|
||||
- name: auth-route
|
||||
paths:
|
||||
- /auth/v1
|
||||
plugins:
|
||||
- name: cors
|
||||
- name: key-auth
|
||||
config:
|
||||
hide_credentials: true
|
||||
|
||||
- name: storage
|
||||
url: http://supabase-db:5432
|
||||
routes:
|
||||
- name: storage-route
|
||||
paths:
|
||||
- /storage/v1
|
||||
plugins:
|
||||
- name: cors
|
||||
- name: key-auth
|
||||
config:
|
||||
hide_credentials: true
|
||||
|
||||
EOL
|
||||
fi
|
||||
|
||||
# Fix any spacing issues in the Kong configuration
|
||||
if [ -f "./backend/supabase/kong.yml" ]; then
|
||||
sed -i '' 's/ey AgC/eyAgC/g' ./backend/supabase/kong.yml
|
||||
fi
|
||||
|
||||
echo "Initialization complete. Run 'docker compose up -d' to start the application."
|
|
@ -0,0 +1,364 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Print colored output
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
RED='\033[0;31m'
|
||||
YELLOW='\033[0;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${BLUE}Starting AgentPress Development Environment${NC}"
|
||||
|
||||
# Load environment variables from .env file
|
||||
if [ -f .env ]; then
|
||||
echo -e "${BLUE}Loading environment variables from .env file...${NC}"
|
||||
set -a
|
||||
source .env
|
||||
set +a
|
||||
else
|
||||
echo -e "${RED}Error: .env file not found in project root${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run cleanup script to ensure all previous services are stopped
|
||||
if [ -f "./cleanup.sh" ]; then
|
||||
echo -e "${BLUE}Running cleanup script...${NC}"
|
||||
bash ./cleanup.sh
|
||||
fi
|
||||
|
||||
# Check if init-dev.sh exists and run it if it does
|
||||
if [ -f "./init-dev.sh" ]; then
|
||||
echo -e "${BLUE}Running initialization script...${NC}"
|
||||
bash ./init-dev.sh
|
||||
fi
|
||||
|
||||
# Create a trap to handle ctrl+c and clean up processes
|
||||
trap 'echo -e "${RED}Shutting down services...${NC}"; kill $(jobs -p) 2>/dev/null; cd backend/supabase && supabase stop; docker stop agentpress-redis 2>/dev/null; docker rm agentpress-redis 2>/dev/null; exit' INT TERM
|
||||
|
||||
# Start Supabase and ensure it starts properly
|
||||
echo -e "${GREEN}Starting Supabase and extracting credentials...${NC}"
|
||||
cd backend/supabase
|
||||
# Start Supabase and store the output
|
||||
supabase start > supabase_output.txt
|
||||
cd ../..
|
||||
|
||||
# Wait to ensure Supabase is fully started
|
||||
echo -e "${YELLOW}Waiting for Supabase to start...${NC}"
|
||||
sleep 5
|
||||
|
||||
# Read output file
|
||||
SUPABASE_OUTPUT=$(cat backend/supabase/supabase_output.txt)
|
||||
echo -e "${YELLOW}Supabase Output:${NC}"
|
||||
echo "$SUPABASE_OUTPUT"
|
||||
|
||||
# Extract Supabase URL and keys from the output
|
||||
SUPABASE_URL=$(echo "$SUPABASE_OUTPUT" | grep "API URL" | awk '{print $3}')
|
||||
SUPABASE_ANON_KEY=$(echo "$SUPABASE_OUTPUT" | grep "anon key" | awk '{print $3}')
|
||||
SUPABASE_SERVICE_ROLE_KEY=$(echo "$SUPABASE_OUTPUT" | grep "service_role key" | awk '{print $3}')
|
||||
|
||||
# Remove temp file
|
||||
rm -f backend/supabase/supabase_output.txt
|
||||
|
||||
# Check if extraction was successful
|
||||
if [ -z "$SUPABASE_URL" ] || [ -z "$SUPABASE_ANON_KEY" ] || [ -z "$SUPABASE_SERVICE_ROLE_KEY" ]; then
|
||||
echo -e "${RED}Failed to extract Supabase credentials from output.${NC}"
|
||||
echo -e "${YELLOW}Manual check - trying to get current Supabase status...${NC}"
|
||||
|
||||
# Try to get the status
|
||||
cd backend/supabase
|
||||
SUPABASE_STATUS=$(supabase status)
|
||||
cd ../..
|
||||
|
||||
echo "$SUPABASE_STATUS"
|
||||
|
||||
# Try to extract again from status output
|
||||
SUPABASE_URL=$(echo "$SUPABASE_STATUS" | grep "API URL" | awk '{print $3}')
|
||||
SUPABASE_ANON_KEY=$(echo "$SUPABASE_STATUS" | grep "anon key" | awk '{print $3}')
|
||||
SUPABASE_SERVICE_ROLE_KEY=$(echo "$SUPABASE_STATUS" | grep "service_role key" | awk '{print $3}')
|
||||
|
||||
# Still failed?
|
||||
if [ -z "$SUPABASE_URL" ] || [ -z "$SUPABASE_ANON_KEY" ] || [ -z "$SUPABASE_SERVICE_ROLE_KEY" ]; then
|
||||
echo -e "${RED}ERROR: Unable to extract Supabase credentials and cannot proceed without them.${NC}"
|
||||
echo -e "${RED}Please start Supabase manually with 'cd backend/supabase && supabase start'${NC}"
|
||||
echo -e "${RED}Then extract the credentials from the output and update environment files manually.${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "${GREEN}Successfully extracted Supabase credentials from status:${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e "${GREEN}Successfully extracted Supabase credentials:${NC}"
|
||||
fi
|
||||
|
||||
echo -e "URL: ${SUPABASE_URL}"
|
||||
echo -e "Anon Key: ${SUPABASE_ANON_KEY}"
|
||||
|
||||
# Special case: If URL is "database", replace with the actual local URL
|
||||
if [ "$SUPABASE_URL" == "database" ]; then
|
||||
echo -e "${YELLOW}URL 'database' is not valid. Using http://127.0.0.1:54321 instead${NC}"
|
||||
SUPABASE_URL="http://127.0.0.1:54321"
|
||||
# Otherwise ensure URL has a proper format
|
||||
elif [[ ! "$SUPABASE_URL" == http://* && ! "$SUPABASE_URL" == https://* ]]; then
|
||||
echo -e "${YELLOW}Adding http:// prefix to URL${NC}"
|
||||
SUPABASE_URL="http://$SUPABASE_URL"
|
||||
fi
|
||||
|
||||
# Update the environment files with the extracted credentials
|
||||
echo -e "${YELLOW}Updating environment variables with extracted Supabase credentials...${NC}"
|
||||
|
||||
# Update the root .env file
|
||||
echo -e "${YELLOW}Updating root .env file...${NC}"
|
||||
sed -i '' "s|^SUPABASE_URL=.*|SUPABASE_URL=\"${SUPABASE_URL}\"|g" .env
|
||||
sed -i '' "s|^SUPABASE_ANON_KEY=.*|SUPABASE_ANON_KEY=\"${SUPABASE_ANON_KEY}\"|g" .env
|
||||
sed -i '' "s|^SUPABASE_SERVICE_ROLE_KEY=.*|SUPABASE_SERVICE_ROLE_KEY=\"${SUPABASE_SERVICE_ROLE_KEY}\"|g" .env
|
||||
sed -i '' "s|^NEXT_PUBLIC_SUPABASE_URL=.*|NEXT_PUBLIC_SUPABASE_URL=\"${SUPABASE_URL}\"|g" .env
|
||||
sed -i '' "s|^NEXT_PUBLIC_SUPABASE_ANON_KEY=.*|NEXT_PUBLIC_SUPABASE_ANON_KEY=\"${SUPABASE_ANON_KEY}\"|g" .env
|
||||
|
||||
# Update the frontend .env.local file
|
||||
echo -e "${YELLOW}Updating frontend/.env.local file...${NC}"
|
||||
sed -i '' "s|^SUPABASE_URL=.*|SUPABASE_URL=\"${SUPABASE_URL}\"|g" frontend/.env.local
|
||||
sed -i '' "s|^SUPABASE_ANON_KEY=.*|SUPABASE_ANON_KEY=\"${SUPABASE_ANON_KEY}\"|g" frontend/.env.local
|
||||
sed -i '' "s|^SUPABASE_SERVICE_ROLE_KEY=.*|SUPABASE_SERVICE_ROLE_KEY=\"${SUPABASE_SERVICE_ROLE_KEY}\"|g" frontend/.env.local
|
||||
sed -i '' "s|^NEXT_PUBLIC_SUPABASE_URL=.*|NEXT_PUBLIC_SUPABASE_URL=\"${SUPABASE_URL}\"|g" frontend/.env.local
|
||||
sed -i '' "s|^NEXT_PUBLIC_SUPABASE_ANON_KEY=.*|NEXT_PUBLIC_SUPABASE_ANON_KEY=\"${SUPABASE_ANON_KEY}\"|g" frontend/.env.local
|
||||
|
||||
# Update the backend .env file with correct Redis and Supabase settings
|
||||
echo -e "${YELLOW}Updating backend/.env file with local Redis and Supabase settings...${NC}"
|
||||
|
||||
# Create or update backend/.env with correct local dev settings
|
||||
cat > backend/.env << EOL
|
||||
# API Keys (loaded from root .env)
|
||||
GROQ_API_KEY="${GROQ_API_KEY}"
|
||||
OPENROUTER_API_KEY="${OPENROUTER_API_KEY}"
|
||||
OPENAI_API_KEY="${OPENAI_API_KEY}"
|
||||
ANTHROPIC_API_KEY="${ANTHROPIC_API_KEY}"
|
||||
EXA_API_KEY="${EXA_API_KEY}"
|
||||
TAVILY_API_KEY="${TAVILY_API_KEY}"
|
||||
RAPID_API_KEY="${RAPID_API_KEY}"
|
||||
|
||||
# URLs
|
||||
NEXT_PUBLIC_URL="${NEXT_PUBLIC_URL}"
|
||||
|
||||
# Local Supabase settings
|
||||
SUPABASE_URL="${SUPABASE_URL}"
|
||||
SUPABASE_ANON_KEY="${SUPABASE_ANON_KEY}"
|
||||
SUPABASE_SERVICE_ROLE_KEY="${SUPABASE_SERVICE_ROLE_KEY}"
|
||||
|
||||
# Local Redis settings
|
||||
REDIS_HOST="${REDIS_HOST:-localhost}"
|
||||
REDIS_PORT="${REDIS_PORT:-6379}"
|
||||
REDIS_PASSWORD="${REDIS_PASSWORD:-}"
|
||||
REDIS_SSL="${REDIS_SSL:-False}"
|
||||
|
||||
# AWS settings
|
||||
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}"
|
||||
AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}"
|
||||
AWS_REGION_NAME="${AWS_REGION_NAME}"
|
||||
|
||||
# Daytona settings
|
||||
DAYTONA_API_KEY="${DAYTONA_API_KEY}"
|
||||
DAYTONA_SERVER_URL="${DAYTONA_SERVER_URL}"
|
||||
DAYTONA_TARGET="${DAYTONA_TARGET}"
|
||||
|
||||
# Model selection
|
||||
MODEL_TO_USE="${MODEL_TO_USE}"
|
||||
|
||||
# Public variables
|
||||
NEXT_PUBLIC_SUPABASE_URL="${SUPABASE_URL}"
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY="${SUPABASE_ANON_KEY}"
|
||||
NEXT_PUBLIC_BACKEND_URL="${NEXT_PUBLIC_BACKEND_URL:-http://localhost:8000/api}"
|
||||
NEXT_PUBLIC_URL="${NEXT_PUBLIC_URL}"
|
||||
NEXT_PUBLIC_GOOGLE_CLIENT_ID="${NEXT_PUBLIC_GOOGLE_CLIENT_ID}"
|
||||
EOL
|
||||
|
||||
# Wait for Supabase to fully start
|
||||
echo -e "${YELLOW}Waiting for Supabase to be fully available...${NC}"
|
||||
# Use a loop to check if Supabase is responding
|
||||
MAX_RETRIES=15
|
||||
RETRY_COUNT=0
|
||||
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
|
||||
if curl --silent --fail "${SUPABASE_URL}/auth/v1/health" > /dev/null; then
|
||||
echo -e "${GREEN}Supabase is up and running!${NC}"
|
||||
break
|
||||
else
|
||||
echo -e "${YELLOW}Waiting for Supabase to start (${RETRY_COUNT}/${MAX_RETRIES})...${NC}"
|
||||
sleep 3
|
||||
RETRY_COUNT=$((RETRY_COUNT+1))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
|
||||
echo -e "${RED}ERROR: Supabase health check timed out after ${MAX_RETRIES} attempts.${NC}"
|
||||
echo -e "${RED}Please verify Supabase is running correctly at ${SUPABASE_URL}${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Apply Supabase migrations
|
||||
echo -e "${YELLOW}Applying Supabase migrations...${NC}"
|
||||
cd backend/supabase
|
||||
MIGRATION_OUTPUT=$(supabase db reset --debug)
|
||||
echo "$MIGRATION_OUTPUT"
|
||||
cd ../..
|
||||
|
||||
# Uncomment test authentication code in auth/page.tsx
|
||||
echo -e "${YELLOW}Enabling test authentication code...${NC}"
|
||||
sed -i '' -e 's|\/\*|\/\* Test login enabled: |g' -e 's|\*\/| \*\/|g' frontend/src/app/auth/page.tsx
|
||||
|
||||
# Create default user in Supabase
|
||||
echo -e "${YELLOW}Creating default user...${NC}"
|
||||
curl -X POST "${SUPABASE_URL}/auth/v1/signup" \
|
||||
-H "apikey: ${SUPABASE_ANON_KEY}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"email": "user@example.com",
|
||||
"password": "password123",
|
||||
"data": {"name": "Default User"}
|
||||
}'
|
||||
echo -e "\n${YELLOW}Default user created: user@example.com / password123${NC}"
|
||||
|
||||
# List all users to verify
|
||||
echo -e "${YELLOW}Listing users in Supabase...${NC}"
|
||||
curl -X GET "${SUPABASE_URL}/auth/v1/admin/users" \
|
||||
-H "apikey: ${SUPABASE_SERVICE_ROLE_KEY}" \
|
||||
-H "Content-Type: application/json" | grep -o '"email":"[^"]*"'
|
||||
|
||||
# Start Redis
|
||||
echo -e "${GREEN}Starting Redis...${NC}"
|
||||
docker run --name agentpress-redis -p 6379:6379 -d redis:latest &
|
||||
sleep 2 # Give Redis time to start
|
||||
|
||||
# Start Backend
|
||||
echo -e "${GREEN}Starting Backend...${NC}"
|
||||
cd backend
|
||||
# Check for Python or Python3 command
|
||||
if command -v python3 &>/dev/null; then
|
||||
python3 -m uvicorn api:app --host 0.0.0.0 --port 8000 --reload &
|
||||
elif command -v python &>/dev/null; then
|
||||
python -m uvicorn api:app --host 0.0.0.0 --port 8000 --reload &
|
||||
else
|
||||
echo -e "${RED}Python not found. Cannot start backend.${NC}"
|
||||
fi
|
||||
cd ..
|
||||
sleep 2 # Give backend time to start
|
||||
|
||||
# Start Frontend
|
||||
echo -e "${GREEN}Starting Frontend...${NC}"
|
||||
cd frontend
|
||||
npm run dev &
|
||||
cd ..
|
||||
|
||||
echo -e "${GREEN}All services are starting!${NC}"
|
||||
echo -e "${BLUE}Frontend will be available at:${NC} http://localhost:3000"
|
||||
echo -e "${BLUE}Backend API will be available at:${NC} http://localhost:8000/api"
|
||||
echo -e "${BLUE}Supabase Studio will be available at:${NC} http://localhost:54323"
|
||||
echo -e "${BLUE}Supabase credentials:${NC}"
|
||||
echo -e " URL: ${SUPABASE_URL}"
|
||||
echo -e " Anon Key: ${SUPABASE_ANON_KEY}"
|
||||
echo -e "${YELLOW}Default login:${NC} user@example.com / password123"
|
||||
echo -e "${BLUE}Press Ctrl+C to stop all services${NC}"
|
||||
|
||||
# Check services health and show progress
|
||||
echo -e "${YELLOW}Monitoring services startup...${NC}"
|
||||
|
||||
# Track service status
|
||||
backend_ready=false
|
||||
frontend_ready=false
|
||||
redis_ready=false
|
||||
|
||||
# Function to print progress bar
|
||||
print_progress() {
|
||||
local service=$1
|
||||
local status=$2
|
||||
local emoji=""
|
||||
|
||||
if [ "$status" == "true" ]; then
|
||||
emoji="✅"
|
||||
else
|
||||
emoji="⏳"
|
||||
fi
|
||||
|
||||
printf "%-15s: %s\n" "$service" "$emoji"
|
||||
}
|
||||
|
||||
# Monitor startup
|
||||
max_attempts=30
|
||||
attempt=0
|
||||
|
||||
while [ $attempt -lt $max_attempts ]; do
|
||||
clear
|
||||
echo -e "${GREEN}AgentPress Services Status:${NC}"
|
||||
echo ""
|
||||
print_progress "Backend" "$backend_ready"
|
||||
print_progress "Frontend" "$frontend_ready"
|
||||
print_progress "Redis" "$redis_ready"
|
||||
echo ""
|
||||
|
||||
# Check backend health
|
||||
if ! $backend_ready; then
|
||||
if curl --silent --fail "http://localhost:8000/api/health" > /dev/null 2>&1; then
|
||||
backend_ready=true
|
||||
echo -e "${GREEN}✅ Backend is now available!${NC}"
|
||||
elif [ $attempt -gt 10 ]; then
|
||||
# After 10 attempts, try to diagnose the issue
|
||||
echo -e "${YELLOW}Checking backend startup logs...${NC}"
|
||||
if ps aux | grep -q "[p]ython.*uvicorn.*api:app"; then
|
||||
echo -e "${YELLOW}Backend process is running but not responding to health checks.${NC}"
|
||||
echo -e "${YELLOW}Possible issues:${NC}"
|
||||
echo -e " - API endpoints may not match expected routes"
|
||||
echo -e " - Backend might be having startup errors"
|
||||
echo -e " - Try checking backend logs for details"
|
||||
else
|
||||
echo -e "${RED}Backend process is not running!${NC}"
|
||||
echo -e "${YELLOW}Attempting to restart backend...${NC}"
|
||||
cd backend
|
||||
if command -v python3 &>/dev/null; then
|
||||
python3 -m uvicorn api:app --host 0.0.0.0 --port 8000 --reload &
|
||||
elif command -v python &>/dev/null; then
|
||||
python -m uvicorn api:app --host 0.0.0.0 --port 8000 --reload &
|
||||
fi
|
||||
cd ..
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check frontend health
|
||||
if ! $frontend_ready; then
|
||||
if curl --silent --fail "http://localhost:3000" > /dev/null 2>&1; then
|
||||
frontend_ready=true
|
||||
echo -e "${GREEN}✅ Frontend is now available!${NC}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check Redis connection
|
||||
if ! $redis_ready; then
|
||||
if docker ps | grep -q "agentpress-redis"; then
|
||||
redis_ready=true
|
||||
echo -e "${GREEN}✅ Redis is now available!${NC}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if all services are ready
|
||||
if $backend_ready && $frontend_ready && $redis_ready; then
|
||||
echo ""
|
||||
echo -e "${GREEN}🚀 All services are up and running!${NC}"
|
||||
echo -e "${BLUE}Frontend:${NC} http://localhost:3000"
|
||||
echo -e "${BLUE}Backend API:${NC} http://localhost:8000/api"
|
||||
echo -e "${BLUE}Supabase Studio:${NC} http://localhost:54323"
|
||||
echo -e "${YELLOW}Default login:${NC} user@example.com / password123"
|
||||
break
|
||||
fi
|
||||
|
||||
# Wait before next check
|
||||
sleep 2
|
||||
attempt=$((attempt+1))
|
||||
|
||||
if [ $attempt -eq $max_attempts ]; then
|
||||
echo ""
|
||||
echo -e "${YELLOW}⚠️ Timeout waiting for all services to start.${NC}"
|
||||
echo -e "${YELLOW}Some services are still initializing and may be available shortly.${NC}"
|
||||
fi
|
||||
done
|
||||
|
||||
echo -e "${BLUE}Press Ctrl+C to stop all services${NC}"
|
||||
|
||||
# Wait for all background processes
|
||||
wait
|
Loading…
Reference in New Issue