server_update.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. # Скрипт автоматического обновления сайта
  3. PROJECT_DIR="/var/www/radionica3d"
  4. echo "==== DEPLOY STARTING: $(date) ===="
  5. cd $PROJECT_DIR
  6. # 1. Забираем код
  7. echo "git pull..."
  8. git pull origin master
  9. # 2. Собираем фронтенд
  10. echo "building frontend..."
  11. npm install --legacy-peer-deps
  12. # Keep old assets briefly to prevent 404 for existing sessions
  13. echo "preserving old assets..."
  14. mkdir -p dist/assets
  15. rm -rf /tmp/radionica_assets_backup
  16. cp -r dist/assets /tmp/radionica_assets_backup || true
  17. bash build_frontend.sh
  18. # Restore old assets (no-clobber, don't overwrite new files)
  19. echo "restoring old assets for compatibility..."
  20. cp -n /tmp/radionica_assets_backup/* dist/assets/ 2>/dev/null || true
  21. # 3. Обновляем бэкенд
  22. echo "updating backend..."
  23. ./backend/venv/bin/pip install -r backend/requirements.txt
  24. # 4. Перезапуск
  25. echo "restarting services..."
  26. sudo systemctl restart radionica-backend
  27. cp /var/www/radionica3d/nginx.conf /etc/nginx/sites-available/radionica3d
  28. sudo systemctl reload nginx
  29. sudo chown -R www-data:www-data $PROJECT_DIR
  30. echo "==== DEPLOY FINISHED: $(date) ===="