Files
usda-vision/dev-logs.sh
salirezav 8e7b5b054f Add development scripts and Docker Compose configuration for local environment setup
- Introduced `dev-start.sh`, `dev-stop.sh`, `dev-logs.sh`, and `dev-shell.sh` for managing the development environment.
- Added `docker-compose.dev.yml` to define services for API and web applications with appropriate configurations.
- Updated `README.md` to include instructions for development mode and commands for managing the environment.
2025-09-11 14:24:21 -04:00

91 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# USDA Vision Development Logs Script
# This script shows logs from the development environment
set -e
echo "📋 USDA Vision Development Logs"
echo "==============================="
# Check if docker-compose.dev.yml exists
if [ ! -f "docker-compose.dev.yml" ]; then
echo "❌ Error: docker-compose.dev.yml not found!"
echo "Please make sure you're in the project root directory."
exit 1
fi
# Function to show help
show_help() {
echo "Usage: $0 [OPTIONS] [SERVICE]"
echo ""
echo "Options:"
echo " -f, --follow Follow log output (like tail -f)"
echo " -t, --tail N Show last N lines (default: 100)"
echo " -h, --help Show this help message"
echo ""
echo "Services:"
echo " api Show API service logs only"
echo " web Show web service logs only"
echo " (no service) Show logs from all services"
echo ""
echo "Examples:"
echo " $0 # Show last 100 lines from all services"
echo " $0 -f # Follow all logs in real-time"
echo " $0 -f api # Follow API logs only"
echo " $0 -t 50 web # Show last 50 lines from web service"
}
# Default values
FOLLOW=false
TAIL_LINES=100
SERVICE=""
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
-f|--follow)
FOLLOW=true
shift
;;
-t|--tail)
TAIL_LINES="$2"
shift 2
;;
-h|--help)
show_help
exit 0
;;
api|web)
SERVICE="$1"
shift
;;
*)
echo "❌ Unknown option: $1"
show_help
exit 1
;;
esac
done
# Build docker compose command
COMPOSE_CMD="docker compose -f docker-compose.dev.yml logs"
if [ "$FOLLOW" = true ]; then
COMPOSE_CMD="$COMPOSE_CMD -f"
fi
if [ "$TAIL_LINES" != "100" ]; then
COMPOSE_CMD="$COMPOSE_CMD --tail=$TAIL_LINES"
fi
if [ -n "$SERVICE" ]; then
COMPOSE_CMD="$COMPOSE_CMD $SERVICE"
fi
echo "Running: $COMPOSE_CMD"
echo ""
# Execute the command
eval $COMPOSE_CMD