retry_env.sh 847 B

1234567891011121314151617181920212223242526
  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 install magic-pdf[full]==0.7.0b1 --extra-index-url https://wheels.myhloli.com -i https://pypi.tuna.tsinghua.edu.cn/simple
  10. pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
  11. exit_code=$?
  12. if [ $exit_code -eq 0 ]; then
  13. echo "test.sh 成功执行!"
  14. break
  15. else
  16. let retry_count+=1
  17. if [ $retry_count -ge $max_retries ]; then
  18. echo "达到最大重试次数 ($max_retries),放弃重试。"
  19. exit 1
  20. fi
  21. echo "test.sh 执行失败 (退出码: $exit_code)。尝试第 $retry_count 次重试..."
  22. sleep 5 # 等待 5 秒后重试
  23. fi
  24. done