Files
gomag-vending/start.sh
Claude Agent b69b5e7104 feat(sync): add GoMag API client with Phase 0 auto-download
- New gomag_client.py service: async httpx client that downloads orders
  from GoMag API with full pagination and 1s rate-limit sleep
- config.py: add GOMAG_API_KEY, GOMAG_API_SHOP, GOMAG_ORDER_DAYS_BACK,
  GOMAG_LIMIT, GOMAG_API_URL settings
- sync_service.py: Phase 0 downloads fresh orders before reading JSONs;
  graceful skip if API keys not configured
- start.sh: auto-detect INSTANTCLIENTPATH from .env, fallback to thin mode
- .env.example: document GoMag API variables

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 23:03:39 +00:00

56 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Start GoMag Import Manager - WSL/Linux
cd "$(dirname "$0")"
# Create venv if it doesn't exist
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3 -m venv venv
fi
# Activate venv
source venv/bin/activate
# Install/update dependencies if needed
if [ api/requirements.txt -nt venv/.deps_installed ] || [ ! -f venv/.deps_installed ]; then
echo "Installing dependencies..."
pip install -r api/requirements.txt
touch venv/.deps_installed
fi
# Stop any existing instance on port 5003
EXISTING_PIDS=$(lsof -ti tcp:5003 2>/dev/null)
if [ -n "$EXISTING_PIDS" ]; then
echo "Stopping existing process(es) on port 5003 (PID $EXISTING_PIDS)..."
echo "$EXISTING_PIDS" | xargs kill 2>/dev/null
sleep 2
fi
# Oracle config
export TNS_ADMIN="$(pwd)/api"
# Detect Oracle Instant Client path from .env or use default
INSTANTCLIENT_PATH=""
if [ -f "api/.env" ]; then
INSTANTCLIENT_PATH=$(grep -E "^INSTANTCLIENTPATH=" api/.env | cut -d'=' -f2- | tr -d ' ')
fi
# Fallback to default path if not set in .env
if [ -z "$INSTANTCLIENT_PATH" ]; then
INSTANTCLIENT_PATH="/opt/oracle/instantclient_21_15"
fi
if [ -d "$INSTANTCLIENT_PATH" ]; then
echo "Oracle Instant Client found: $INSTANTCLIENT_PATH (thick mode)"
export LD_LIBRARY_PATH="$INSTANTCLIENT_PATH:$LD_LIBRARY_PATH"
else
echo "WARN: Oracle Instant Client NOT found la: $INSTANTCLIENT_PATH"
echo " Se va folosi thin mode (Oracle 12.1+ necesar)."
echo " Pentru thick mode: instaleaza instantclient sau seteaza INSTANTCLIENTPATH in api/.env"
# Force thin mode so app doesn't try to load missing libraries
export FORCE_THIN_MODE=true
fi
cd api
echo "Starting GoMag Import Manager on http://0.0.0.0:5003"
python -m uvicorn app.main:app --host 0.0.0.0 --port 5003