Fix menu.sh service counting robustness
- Add error handling to prevent script crashes during service enumeration - Make service counting more robust against parsing failures - Ensure menu displays properly even with docker-compose parsing issues - Menu now shows complete interface with all 8 main options
This commit is contained in:
@@ -130,11 +130,21 @@ show_system_status() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Service count
|
# Service count
|
||||||
local service_count
|
local service_count=0
|
||||||
service_count=$(find_all_services | wc -l)
|
local running_count=0
|
||||||
if (( service_count > 0 )); then
|
|
||||||
local running_count
|
# Safely count services with error handling
|
||||||
running_count=$(find_all_services | while read -r service; do is_service_running "$service" && echo "1"; done | wc -l)
|
if service_list=$(find_all_services 2>/dev/null); then
|
||||||
|
service_count=$(echo "$service_list" | wc -l 2>/dev/null || echo "0")
|
||||||
|
# Remove whitespace and ensure it's a number
|
||||||
|
service_count=$(echo "$service_count" | tr -d '[:space:]' | sed 's/[^0-9]*//g')
|
||||||
|
if [[ "$service_count" =~ ^[0-9]+$ ]] && (( service_count > 0 )); then
|
||||||
|
running_count=$(echo "$service_list" | while read -r service; do is_service_running "$service" 2>/dev/null && echo "1"; done | wc -l 2>/dev/null || echo "0")
|
||||||
|
running_count=$(echo "$running_count" | tr -d '[:space:]' | sed 's/[^0-9]*//g')
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$service_count" =~ ^[0-9]+$ ]] && (( service_count > 0 )); then
|
||||||
echo "✅ Services: $running_count/$service_count running"
|
echo "✅ Services: $running_count/$service_count running"
|
||||||
else
|
else
|
||||||
echo "ℹ️ Services: None deployed yet"
|
echo "ℹ️ Services: None deployed yet"
|
||||||
|
|||||||
Reference in New Issue
Block a user