|
1 | 1 | #!/bin/bash
|
2 | 2 | # Startup script for Superset in Codespaces
|
3 | 3 |
|
4 |
| -# Log to a file for debugging |
5 |
| -LOG_FILE="/tmp/superset-startup.log" |
6 |
| -echo "[$(date)] Starting Superset startup script" >> "$LOG_FILE" |
7 |
| -echo "[$(date)] User: $(whoami), PWD: $(pwd)" >> "$LOG_FILE" |
8 |
| - |
9 | 4 | echo "🚀 Starting Superset in Codespaces..."
|
10 | 5 | echo "🌐 Frontend will be available at port 9001"
|
11 | 6 |
|
| 7 | +# Check if MCP is enabled |
| 8 | +if [ "$ENABLE_MCP" = "true" ]; then |
| 9 | + echo "🤖 MCP Service will be available at port 5008" |
| 10 | +fi |
| 11 | + |
12 | 12 | # Find the workspace directory (Codespaces clones as 'superset', not 'superset-2')
|
13 | 13 | WORKSPACE_DIR=$(find /workspaces -maxdepth 1 -name "superset*" -type d | head -1)
|
14 | 14 | if [ -n "$WORKSPACE_DIR" ]; then
|
|
18 | 18 | echo "📁 Using current directory: $(pwd)"
|
19 | 19 | fi
|
20 | 20 |
|
21 |
| -# Wait for Docker to be available |
22 |
| -echo "⏳ Waiting for Docker to start..." |
23 |
| -echo "[$(date)] Waiting for Docker..." >> "$LOG_FILE" |
24 |
| -max_attempts=30 |
25 |
| -attempt=0 |
26 |
| -while ! docker info > /dev/null 2>&1; do |
27 |
| - if [ $attempt -eq $max_attempts ]; then |
28 |
| - echo "❌ Docker failed to start after $max_attempts attempts" |
29 |
| - echo "[$(date)] Docker failed to start after $max_attempts attempts" >> "$LOG_FILE" |
30 |
| - echo "🔄 Please restart the Codespace or run this script manually later" |
31 |
| - exit 1 |
32 |
| - fi |
33 |
| - echo " Attempt $((attempt + 1))/$max_attempts..." |
34 |
| - echo "[$(date)] Docker check attempt $((attempt + 1))/$max_attempts" >> "$LOG_FILE" |
35 |
| - sleep 2 |
36 |
| - attempt=$((attempt + 1)) |
37 |
| -done |
38 |
| -echo "✅ Docker is ready!" |
39 |
| -echo "[$(date)] Docker is ready" >> "$LOG_FILE" |
40 |
| - |
41 |
| -# Check if Superset containers are already running |
42 |
| -if docker ps | grep -q "superset"; then |
43 |
| - echo "✅ Superset containers are already running!" |
44 |
| - echo "" |
45 |
| - echo "🌐 To access Superset:" |
46 |
| - echo " 1. Click the 'Ports' tab at the bottom of VS Code" |
47 |
| - echo " 2. Find port 9001 and click the globe icon to open" |
48 |
| - echo " 3. Wait 10-20 minutes for initial startup" |
49 |
| - echo "" |
50 |
| - echo "📝 Login credentials: admin/admin" |
51 |
| - exit 0 |
| 21 | +# Check if docker is running |
| 22 | +if ! docker info > /dev/null 2>&1; then |
| 23 | + echo "⏳ Waiting for Docker to start..." |
| 24 | + sleep 5 |
52 | 25 | fi
|
53 | 26 |
|
54 | 27 | # Clean up any existing containers
|
55 | 28 | echo "🧹 Cleaning up existing containers..."
|
56 |
| -docker-compose -f docker-compose-light.yml down |
| 29 | +docker-compose -f docker-compose-light.yml --profile mcp down |
57 | 30 |
|
58 | 31 | # Start services
|
59 |
| -echo "🏗️ Starting Superset in background (daemon mode)..." |
| 32 | +echo "🏗️ Building and starting services..." |
60 | 33 | echo ""
|
61 |
| - |
62 |
| -# Start in detached mode |
63 |
| -docker-compose -f docker-compose-light.yml up -d |
64 |
| - |
65 |
| -echo "" |
66 |
| -echo "✅ Docker Compose started successfully!" |
67 |
| -echo "" |
68 |
| -echo "📋 Important information:" |
69 |
| -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
70 |
| -echo "⏱️ Initial startup takes 10-20 minutes" |
71 |
| -echo "🌐 Check the 'Ports' tab for your Superset URL (port 9001)" |
72 |
| -echo "👤 Login: admin / admin" |
| 34 | +echo "📝 Once started, login with:" |
| 35 | +echo " Username: admin" |
| 36 | +echo " Password: admin" |
73 | 37 | echo ""
|
74 |
| -echo "📊 Useful commands:" |
75 |
| -echo " docker-compose -f docker-compose-light.yml logs -f # Follow logs" |
76 |
| -echo " docker-compose -f docker-compose-light.yml ps # Check status" |
77 |
| -echo " docker-compose -f docker-compose-light.yml down # Stop services" |
78 |
| -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
79 |
| -echo "" |
80 |
| -echo "💤 Keeping terminal open for 60 seconds to test persistence..." |
81 |
| -sleep 60 |
82 |
| -echo "✅ Test complete - check if this terminal is still visible!" |
| 38 | +echo "📋 Running in foreground with live logs (Ctrl+C to stop)..." |
83 | 39 |
|
84 |
| -# Show final status |
85 |
| -docker-compose -f docker-compose-light.yml ps |
| 40 | +# Run docker-compose and capture exit code |
| 41 | +if [ "$ENABLE_MCP" = "true" ]; then |
| 42 | + echo "🤖 Starting with MCP Service enabled..." |
| 43 | + docker-compose -f docker-compose-light.yml --profile mcp up |
| 44 | +else |
| 45 | + docker-compose -f docker-compose-light.yml up |
| 46 | +fi |
86 | 47 | EXIT_CODE=$?
|
87 | 48 |
|
88 | 49 | # If it failed, provide helpful instructions
|
|
0 commit comments