Files
managing-apps/scripts/list-api-workers-processes.sh
cryptooda ab08e0241b Update Vibe Kanban setup and scripts
- Added new entries to .gitignore for environment files and dynamically generated Docker Compose files.
- Updated documentation to reflect the new path for the Vibe Kanban dev server script.
- Enhanced task composition scripts to extract TASK_SLOT from TASK_ID, ensuring unique Orleans ports and preventing conflicts.
- Removed the old vibe-dev-server script, consolidating functionality into the new structure.
2025-12-31 04:36:20 +07:00

148 lines
4.9 KiB
Bash
Executable File

#!/bin/bash
# scripts/list-api-workers-processes.sh
# Lists all processes related to API and Workers for a given task
TASK_ID=$1
# Try to get TASK_ID from environment if not provided
if [ -z "$TASK_ID" ] && [ -n "$VIBE_TASK_ID" ]; then
TASK_ID="$VIBE_TASK_ID"
fi
# Determine project root
if [ -n "$VIBE_WORKTREE_ROOT" ] && [ -d "$VIBE_WORKTREE_ROOT/src/Managing.Api" ]; then
PROJECT_ROOT="$VIBE_WORKTREE_ROOT"
elif [ -d "$(pwd)/scripts" ] && [ -f "$(pwd)/scripts/start-api-and-workers.sh" ]; then
PROJECT_ROOT="$(pwd)"
else
MAIN_REPO="/Users/oda/Desktop/Projects/managing-apps"
if [ -d "$MAIN_REPO/scripts" ]; then
PROJECT_ROOT="$MAIN_REPO"
else
echo "❌ Error: Cannot find project root"
exit 1
fi
fi
PID_DIR="$PROJECT_ROOT/.task-pids"
API_PID_FILE="$PID_DIR/api-${TASK_ID}.pid"
WORKERS_PID_FILE="$PID_DIR/workers-${TASK_ID}.pid"
if [ -z "$TASK_ID" ]; then
echo "📋 Listing ALL API and Workers processes..."
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "🔍 All dotnet run processes:"
ps aux | grep "dotnet run" | grep -v grep || echo " (none found)"
echo ""
echo "🔍 All Managing.Api processes:"
ps aux | grep "Managing.Api" | grep -v grep || echo " (none found)"
echo ""
echo "🔍 All Managing.Workers processes:"
ps aux | grep "Managing.Workers" | grep -v grep || echo " (none found)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "💡 To list processes for a specific task, run: $0 <TASK_ID>"
exit 0
fi
echo "📋 Listing processes for task: $TASK_ID"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# Check API processes
if [ -f "$API_PID_FILE" ]; then
API_PID=$(cat "$API_PID_FILE")
echo "📊 API Process (from PID file):"
echo " PID File: $API_PID_FILE"
echo " Stored PID: $API_PID"
if ps -p "$API_PID" > /dev/null 2>&1; then
echo " ✅ Process is running"
echo " Process details:"
ps -p "$API_PID" -o pid,ppid,user,%cpu,%mem,etime,command | head -2
echo ""
# Find child processes
echo " Child processes:"
CHILD_PIDS=$(pgrep -P "$API_PID" 2>/dev/null)
if [ -n "$CHILD_PIDS" ]; then
for CHILD_PID in $CHILD_PIDS; do
ps -p "$CHILD_PID" -o pid,ppid,user,%cpu,%mem,etime,command 2>/dev/null | tail -1
done
else
echo " (no child processes found)"
fi
else
echo " ⚠️ Process not running (stale PID file)"
fi
else
echo "📊 API Process:"
echo " ⚠️ PID file not found: $API_PID_FILE"
fi
echo ""
# Check Workers processes
if [ -f "$WORKERS_PID_FILE" ]; then
WORKERS_PID=$(cat "$WORKERS_PID_FILE")
echo "📊 Workers Process (from PID file):"
echo " PID File: $WORKERS_PID_FILE"
echo " Stored PID: $WORKERS_PID"
if ps -p "$WORKERS_PID" > /dev/null 2>&1; then
echo " ✅ Process is running"
echo " Process details:"
ps -p "$WORKERS_PID" -o pid,ppid,user,%cpu,%mem,etime,command | head -2
echo ""
# Find child processes
echo " Child processes:"
CHILD_PIDS=$(pgrep -P "$WORKERS_PID" 2>/dev/null)
if [ -n "$CHILD_PIDS" ]; then
for CHILD_PID in $CHILD_PIDS; do
ps -p "$CHILD_PID" -o pid,ppid,user,%cpu,%mem,etime,command 2>/dev/null | tail -1
done
else
echo " (no child processes found)"
fi
else
echo " ⚠️ Process not running (stale PID file)"
fi
else
echo "📊 Workers Process:"
echo " ⚠️ PID file not found: $WORKERS_PID_FILE"
fi
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# Find processes by executable name (in case PID files are missing)
echo "🔍 Searching for processes by executable name:"
echo ""
API_PROCESSES=$(ps aux | grep "Managing.Api" | grep -v grep | grep "$TASK_ID\|worktree" || true)
if [ -n "$API_PROCESSES" ]; then
echo "📊 Found Managing.Api processes:"
echo "$API_PROCESSES" | while read line; do
echo " $line"
done
else
echo "📊 Managing.Api processes: (none found)"
fi
echo ""
WORKERS_PROCESSES=$(ps aux | grep "Managing.Workers" | grep -v grep | grep "$TASK_ID\|worktree" || true)
if [ -n "$WORKERS_PROCESSES" ]; then
echo "📊 Found Managing.Workers processes:"
echo "$WORKERS_PROCESSES" | while read line; do
echo " $line"
done
else
echo "📊 Managing.Workers processes: (none found)"
fi
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"