Troubleshooting
Setup Issues
400 Response when calling deployment API
Startup Issues
botocore.exceptions.NoCredentialsError
Pulling Logs
#!/bin/bash
# Check if the script is running in a folder with docker-compose.yml containing 'taas_app'
if [ ! -f "docker-compose.yml" ]; then
echo "docker-compose.yml file not found. Please cd to the appropriate folder with the latest taas_app docker-compose.yml file."
exit 1
fi
if ! grep -q "name: taas_app" docker-compose.yml; then
echo "The docker-compose.yml file does not contain an entry with 'name: taas_app'. Please check the file and try again."
exit 1
fi
# Default output folder
OUTPUT_DIR="/tmp"
# Allow user to specify a different output folder
if [ "$1" ]; then
OUTPUT_DIR="$1"
fi
# Ensure the output directory exists
mkdir -p "$OUTPUT_DIR"
# Print message about output folder
echo "Output will be saved to: $OUTPUT_DIR"
# Check available disk space in the output folder
AVAILABLE_SPACE=$(df --output=avail "$OUTPUT_DIR" | tail -1)
if [ "$AVAILABLE_SPACE" -lt 1000000 ]; then
echo "Not enough disk space in $OUTPUT_DIR. At least 1G is required."
exit 1
fi
# Check if gzip is available
if ! command -v gzip &> /dev/null; then
echo "gzip could not be found. Please install it and try again."
exit 1
fi
# Check if tar is available
if ! command -v tar &> /dev/null; then
echo "tar could not be found. Please install it and try again."
exit 1
fi
# Temp folder to hold individual logs
TEMP_DIR="$(mktemp -d)"
# Loop through containers starting with 'taas_app'
for CONTAINER in $(docker ps -a --filter "name=taas_app" --format "{{.Names}}"); do
echo "Processing logs for container: $CONTAINER"
# Dump logs to a file
LOG_FILE="$TEMP_DIR/$CONTAINER.log"
docker logs "$CONTAINER" >& "$LOG_FILE"
# Compress the individual log file
gzip -9 "$LOG_FILE"
done
# Add timestamp to the final gzip archive
TIMESTAMP=$(date +%Y%m%d%H%M%S)
FINAL_TAR="$OUTPUT_DIR/taas_app_logs_$TIMESTAMP.tar"
tar -cf "$FINAL_TAR" -C "$TEMP_DIR" .
# Clean up temporary files
rm -rf "$TEMP_DIR"
# Inform about the compressed log file
echo "Logs have been compressed and saved to: $FINAL_TAR"
# Prompt user to confirm log collection
echo ""
echo "IMPORTANT: Please ensure you have copied the log files from: $FINAL_TAR"
read -p "please confirm logs are copied and you want to continue to restart? (Y/y to continue): " LOG_COLLECTED
# Validate user input
case "$LOG_COLLECTED" in
[yY])
# Perform docker-compose down and up with --remove-orphans
echo "Restarting docker-compose services..."
docker compose down --remove-orphans
docker compose up -d
echo "Restart is complete."
;;
*)
echo "Exiting the script, and restart is skipped. Log files are located at: $FINAL_TAR"
exit 1
;;
esacLast updated
Was this helpful?