Nav apraksta

iris_updater.sh 1001B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. echo "=== IRIS UPDATES ==="
  2. echo "Will unpack $1"
  3. echo "Target IRIS directory is $2"
  4. pkill gunicorn
  5. sleep 2
  6. pkill gunicorn
  7. TMP_DIR=/tmp/iris_updates
  8. if [ -d $TMP_DIR ]
  9. then
  10. echo "Cleaning previous updates temporary files"
  11. rm -rf $TMP_DIR
  12. fi
  13. mkdir -p /tmp/iris_updates
  14. echo "Started unpacking update archive"
  15. unzip -q $1 -d /tmp/iris_updates
  16. echo "Done"
  17. echo "Applying updates"
  18. rsync -av --checksum $TMP_DIR/source/ $2
  19. echo "Upgrading packages"
  20. cd $2
  21. pip3 install -r requirements.txt
  22. echo "Done"
  23. # If need reboot
  24. if [[ $6 -eq 1 ]]
  25. then
  26. # cd to update directory
  27. cd $2
  28. if [ $4 == "worker" ]
  29. then
  30. echo "Restarting IRIS worker"
  31. celery -A app.celery control shutdown
  32. sleep 2
  33. exec celery -A app.celery worker -E -B -l INFO
  34. else
  35. echo "Restarting IRIS Web app"
  36. exec gunicorn app:app --worker-class eventlet --bind 0.0.0.0:8000 --timeout 180 --worker-connections 1000 --log-level=info
  37. fi # Worker condition
  38. fi # restart condition
  39. echo "Updates applied"