add insurance processor script

This commit is contained in:
ipu 2025-07-28 20:33:11 +03:00
parent 4f82307cd9
commit bf1d988d36
21 changed files with 372 additions and 1552 deletions

View file

@ -0,0 +1,50 @@
#!/bin/bash
# Insurance Plan Processor Cron Script
# This script runs the insurance plan processor from within the Docker container
# Set script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
# Log file for cron output
LOG_FILE="$PROJECT_DIR/logs/insurance_processor.log"
ERROR_LOG_FILE="$PROJECT_DIR/logs/insurance_processor_error.log"
# Create logs directory if it doesn't exist
mkdir -p "$(dirname "$LOG_FILE")"
# Function to log messages
log_message() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE"
}
log_error() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - ERROR: $1" | tee -a "$ERROR_LOG_FILE"
}
# Log start of execution
log_message "Starting insurance plan processor..."
# Check if Docker Compose is running
if ! docker compose ps --services --filter "status=running" | grep -q "lolly-api"; then
log_error "Docker Compose service 'lolly-api' is not running"
exit 1
fi
# Change to project directory
cd "$PROJECT_DIR" || {
log_error "Failed to change to project directory: $PROJECT_DIR"
exit 1
}
# Run the insurance plan processor
log_message "Executing insurance plan processor..."
if docker compose exec -T lolly-api uv run python ./src/insurance_plan_processor.py; then
log_message "Insurance plan processor completed successfully"
exit 0
else
log_error "Insurance plan processor failed with exit code $?"
exit 1
fi