start_batch_ingest.sh 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. #ident "@(#)$Format:LocalFoodAI:app.py:%an:%ae:%ad:%cn:%ce:%cd:%H:%D:%N$"
  3. # Local Food AI - Disconnected Ingestion Wrapper
  4. # This script uses nohup to run the python ingestion script in the background.
  5. # You can exit your SSH session safely after starting this script.
  6. echo "========================================================="
  7. echo "🍔 Local Food AI: Extreme Batch Ingestion"
  8. echo "========================================================="
  9. if [ ! -f "en.openfoodfacts.org.products.csv" ] && [ ! -f "fr.openfoodfacts.org.products.csv" ]; then
  10. echo "❌ Error: CSV files not found in the current directory."
  11. echo "Please download the massive CSVs before running this batch."
  12. exit 1
  13. fi
  14. echo "🚀 Starting database wipe and reset..."
  15. # Automatically run the new DB setup to drop the rigid table
  16. venv/bin/python3 setup_db.py
  17. echo "🚀 Triggering background ingestion process via nohup..."
  18. echo "All outputs will be saved to ingestion_process.log"
  19. # Run securely in background
  20. nohup venv/bin/python3 -u ingest_csv.py > ingestion_process.log 2>&1 &
  21. BG_PID=$!
  22. echo "✅ Process started in the background (PID: $BG_PID)"
  23. echo "You can now safely close your terminal or turn off your computer."
  24. echo "To monitor progress from the server later, run:"
  25. echo " tail -f ingestion_process.log"