Files
chat/run_gateway.sh
Andrew K. Choi 91c7e04474
All checks were successful
continuous-integration/drone/push Build is passing
API refactor
2025-10-07 16:25:52 +09:00

51 lines
2.1 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Запуск API Gateway для приложения Women Safety
echo -e "\033[1;34m🚀 Запуск API Gateway на порту 8000 для мобильного приложения...\033[0m"
# Переход в директорию проекта
cd "$(dirname "$0")" || { echo "Не удалось перейти в директорию проекта"; exit 1; }
# Активация виртуального окружения, если оно существует
if [ -d "venv" ]; then
echo -e "\033[1;33m🔄 Активация виртуального окружения...\033[0m"
source venv/bin/activate
elif [ -d ".venv" ]; then
echo -e "\033[1;33m🔄 Активация виртуального окружения...\033[0m"
source .venv/bin/activate
fi
# Установка переменной PYTHONPATH
export PYTHONPATH="${PWD}:${PYTHONPATH}"
# Создание Python-скрипта для миграции базы данных
echo -e "\033[1;33m🔄 Создание временного скрипта для миграции базы данных...\033[0m"
cat > migrate_db.py << 'EOL'
import asyncio
import sys
async def run_migrations():
from shared.database import init_db
print("🔄 Выполнение миграций базы данных...")
await init_db()
print("✅ Миграции успешно выполнены!")
if __name__ == "__main__":
asyncio.run(run_migrations())
EOL
# Запуск миграции базы данных
echo -e "\033[1;33m🔄 Запуск миграции базы данных...\033[0m"
python migrate_db.py
MIGRATION_STATUS=$?
if [ $MIGRATION_STATUS -ne 0 ]; then
echo -e "\033[1;31m❌ Ошибка при миграции базы данных. Проверьте логи.\033[0m"
exit 1
fi
# Запуск API Gateway
echo -e "\033[1;32m✅ Запуск API Gateway...\033[0m"
cd services/api_gateway || { echo "Не удалось перейти в директорию API Gateway"; exit 1; }
python -m uvicorn main:app --host 0.0.0.0 --port 8000