Files
soleprint/mainroom/ctrl/logs.sh
buenosairesam 9319d0ade6 lastest changes
2025-12-31 12:44:30 -03:00

50 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# View mainroom logs
#
# Usage:
# ./logs.sh # All logs
# ./logs.sh <service> # Service compose logs (e.g., amar, soleprint)
# ./logs.sh <container> # Specific container name (e.g., backend, db)
set -e
# Change to parent directory (services are in ../service_name)
cd "$(dirname "$0")/.."
# Export mainroom/.env vars
if [ -f ".env" ]; then
set -a
source .env
set +a
fi
TARGET=${1:-all}
SERVICE_DIRS=()
# Find all service directories (have docker-compose.yml, exclude ctrl/nginx)
for dir in */; do
dirname="${dir%/}"
if [ -f "$dir/docker-compose.yml" ] && [ "$dirname" != "ctrl" ] && [ "$dirname" != "nginx" ]; then
SERVICE_DIRS+=("$dirname")
fi
done
if [[ " ${SERVICE_DIRS[@]} " =~ " ${TARGET} " ]]; then
# Service directory logs
cd "$TARGET" && docker compose logs -f
elif [ "$TARGET" = "all" ]; then
# All containers from all services
echo "Tailing logs for: ${SERVICE_DIRS[*]}"
for service in "${SERVICE_DIRS[@]}"; do
cd "$service"
docker compose logs -f &
cd ..
done
wait
else
# Specific container name - try exact match
docker logs -f "$TARGET" 2>/dev/null || \
echo "Container not found: $TARGET"
echo "Use service name (e.g., ./logs.sh soleprint) or full container name"
fi