Enhance start-api-and-workers.sh and vibe-dev-server.sh scripts

- Added support for Swagger in the API by setting EnableSwagger environment variable.
- Implemented build error handling for both API and Workers, providing detailed feedback and suggestions for resolution.
- Updated vibe-dev-server.sh to start the API and Workers using Aspire, including improved logging and dashboard URL extraction.
- Enhanced waiting mechanisms for API readiness and Aspire dashboard availability, ensuring smoother startup experience.
This commit is contained in:
2025-12-31 05:23:07 +07:00
parent ab08e0241b
commit cef86a5025
9 changed files with 357 additions and 135 deletions

View File

@@ -56,6 +56,7 @@ WORKERS_PID_FILE="$PID_DIR/workers-${TASK_ID}.pid"
# Set environment variables for API
export ASPNETCORE_ENVIRONMENT=Development
export ASPNETCORE_URLS="http://localhost:${API_PORT}"
export EnableSwagger=true
export RUN_ORLEANS_GRAINS=true
export SILO_ROLE=Trading
export TASK_SLOT=${TASK_SLOT}
@@ -93,8 +94,28 @@ fi
echo "🚀 Starting API on port $API_PORT..."
echo "📁 Running from: $PROJECT_ROOT"
echo "📚 Swagger enabled: true"
cd "$PROJECT_ROOT/src/Managing.Api"
# Try to build first to catch build errors early
echo "🔨 Building API project..."
if ! dotnet build --no-incremental > "$PID_DIR/api-${TASK_ID}-build.log" 2>&1; then
echo "❌ Build failed! Showing build errors:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
tail -n 50 "$PID_DIR/api-${TASK_ID}-build.log" 2>/dev/null || cat "$PID_DIR/api-${TASK_ID}-build.log" 2>/dev/null
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "💡 Try:"
echo " 1. Clean build: cd $PROJECT_ROOT/src/Managing.Api && dotnet clean && dotnet build"
echo " 2. Disable parallel builds: export DOTNET_CLI_MSBUILD_PARALLEL=0"
echo " 3. Check for compilation errors in the log above"
exit 1
fi
echo "✅ Build successful"
# Write all output to log file (warnings will be filtered when displaying)
# Disable parallel MSBuild nodes to avoid child node crashes
export DOTNET_CLI_MSBUILD_PARALLEL=0
dotnet run > "$PID_DIR/api-${TASK_ID}.log" 2>&1 &
API_PID=$!
echo $API_PID > "$API_PID_FILE"
@@ -105,18 +126,39 @@ sleep 3
echo "🚀 Starting Workers..."
cd "$PROJECT_ROOT/src/Managing.Workers"
# Set workers environment variables (separate from API)
# Write all output to log file (warnings will be filtered when displaying)
ASPNETCORE_ENVIRONMENT=Development \
PostgreSql__ConnectionString="Host=localhost;Port=${POSTGRES_PORT};Database=${DB_NAME};Username=postgres;Password=postgres" \
InfluxDb__Url="http://localhost:8086/" \
InfluxDb__Token="Fw2FPL2OwTzDHzSbR2Sd5xs0EKQYy00Q-hYKYAhr9cC1_q5YySONpxuf_Ck0PTjyUiF13xXmi__bu_pXH-H9zA==" \
KAIGEN_SECRET_KEY="KaigenXCowchain" \
Flagsmith__ApiKey="ser.ShJJJMtWYS9fwuzd83ejwR" \
dotnet run > "$PID_DIR/workers-${TASK_ID}.log" 2>&1 &
WORKERS_PID=$!
echo $WORKERS_PID > "$WORKERS_PID_FILE"
echo "✅ Workers started (PID: $WORKERS_PID) from worktree: $PROJECT_ROOT"
# Try to build first to catch build errors early
echo "🔨 Building Workers project..."
if ! dotnet build --no-incremental > "$PID_DIR/workers-${TASK_ID}-build.log" 2>&1; then
echo "❌ Build failed! Showing build errors:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
tail -n 50 "$PID_DIR/workers-${TASK_ID}-build.log" 2>/dev/null || cat "$PID_DIR/workers-${TASK_ID}-build.log" 2>/dev/null
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "💡 Try:"
echo " 1. Clean build: cd $PROJECT_ROOT/src/Managing.Workers && dotnet clean && dotnet build"
echo " 2. Disable parallel builds: export DOTNET_CLI_MSBUILD_PARALLEL=0"
echo " 3. Check for compilation errors in the log above"
# Don't exit - API might still be running
echo "⚠️ Continuing without Workers..."
else
echo "✅ Build successful"
# Set workers environment variables (separate from API)
# Write all output to log file (warnings will be filtered when displaying)
# Disable parallel MSBuild nodes to avoid child node crashes
export DOTNET_CLI_MSBUILD_PARALLEL=0
ASPNETCORE_ENVIRONMENT=Development \
PostgreSql__ConnectionString="Host=localhost;Port=${POSTGRES_PORT};Database=${DB_NAME};Username=postgres;Password=postgres" \
InfluxDb__Url="http://localhost:8086/" \
InfluxDb__Token="Fw2FPL2OwTzDHzSbR2Sd5xs0EKQYy00Q-hYKYAhr9cC1_q5YySONpxuf_Ck0PTjyUiF13xXmi__bu_pXH-H9zA==" \
KAIGEN_SECRET_KEY="KaigenXCowchain" \
Flagsmith__ApiKey="ser.ShJJJMtWYS9fwuzd83ejwR" \
dotnet run > "$PID_DIR/workers-${TASK_ID}.log" 2>&1 &
WORKERS_PID=$!
echo $WORKERS_PID > "$WORKERS_PID_FILE"
echo "✅ Workers started (PID: $WORKERS_PID) from worktree: $PROJECT_ROOT"
fi
echo ""
echo "✅ API and Workers started!"