retry_env.sh 825 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. # 定义最大重试次数
  3. max_retries=5
  4. retry_count=0
  5. while true; do
  6. # prepare env
  7. source activate MinerU
  8. pip install -r requirements-qa.txt
  9. pip uninstall magic-pdf
  10. pip install -U magic-pdf[full] --extra-index-url https://wheels.myhloli.com
  11. pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
  12. exit_code=$?
  13. if [ $exit_code -eq 0 ]; then
  14. echo "test.sh 成功执行!"
  15. break
  16. else
  17. let retry_count+=1
  18. if [ $retry_count -ge $max_retries ]; then
  19. echo "达到最大重试次数 ($max_retries),放弃重试。"
  20. exit 1
  21. fi
  22. echo "test.sh 执行失败 (退出码: $exit_code)。尝试第 $retry_count 次重试..."
  23. sleep 5 # 等待 5 秒后重试
  24. fi
  25. done