retry_env.sh 793 B

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