changed db engine to mysql
All checks were successful
Deploy FluentGerman.ai / deploy (push) Successful in 50s

This commit is contained in:
2026-02-12 22:11:41 +01:00
parent ababfc7c08
commit 1406c95fea
6 changed files with 20 additions and 17 deletions

View File

@@ -79,8 +79,8 @@ jobs:
pip install --quiet -r requirements.txt
# Restart service
sudo systemctl restart fluentgerman
echo "✓ FluentGerman.ai deployed and restarted"
#sudo systemctl restart fluentgerman
echo "✓ FluentGerman.ai deployed"
REMOTE_SCRIPT
# Cleanup

View File

@@ -8,8 +8,8 @@ APP_PORT=8999
SECRET_KEY=generate-a-strong-random-key-here
ACCESS_TOKEN_EXPIRE_MINUTES=1440
# Database (PostgreSQL)
DATABASE_URL=postgresql+asyncpg://fluentgerman:YOUR_PASSWORD@localhost:5432/fluentgerman
# Database (MySQL)
DATABASE_URL=mysql+aiomysql://fluentgerman:YOUR_PASSWORD@localhost:3306/fluentgerman
# LLM Provider (via LiteLLM — supports openai, anthropic, gemini, etc.)
# For Gemini: set LLM_PROVIDER=gemini, LLM_MODEL=gemini-2.0-flash (auto-prefixed)

View File

@@ -19,7 +19,7 @@ class Settings(BaseSettings):
algorithm: str = "HS256"
# Database
database_url: str = "postgresql+asyncpg://fluentgerman:fluentgerman@localhost:5432/fluentgerman"
database_url: str = "mysql+aiomysql://fluentgerman:fluentgerman@localhost:3306/fluentgerman"
# LLM
llm_provider: str = "openai" # used by litellm routing

View File

@@ -1,4 +1,4 @@
"""FluentGerman.ai — Database setup (async PostgreSQL)."""
"""FluentGerman.ai — Database setup (async MySQL)."""
from collections.abc import AsyncGenerator
@@ -7,7 +7,11 @@ from sqlalchemy.orm import DeclarativeBase
from app.config import get_settings
engine = create_async_engine(get_settings().database_url, echo=get_settings().debug)
engine = create_async_engine(
get_settings().database_url,
echo=get_settings().debug,
pool_recycle=3600, # Reconnect before MySQL's wait_timeout (default 8h)
)
async_session = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)

View File

@@ -2,7 +2,7 @@
fastapi[standard]>=0.115.0
uvicorn[standard]>=0.32.0
sqlalchemy[asyncio]>=2.0.0
asyncpg>=0.30.0
aiomysql>=0.2.0
pydantic[email]>=2.0.0
pydantic-settings>=2.0.0
python-jose[cryptography]>=3.3.0

View File

@@ -23,14 +23,13 @@ apt-get update -qq
apt-get install -y -qq python3 python3-venv python3-pip > /dev/null
echo "✓ Python installed"
# 3. PostgreSQL database setup
sudo -u postgres psql -tc "SELECT 1 FROM pg_roles WHERE rolname='$DB_USER'" | grep -q 1 || \
sudo -u postgres psql -c "CREATE USER $DB_USER WITH PASSWORD 'CHANGE_ME';"
sudo -u postgres psql -tc "SELECT 1 FROM pg_database WHERE datname='$DB_NAME'" | grep -q 1 || \
sudo -u postgres psql -c "CREATE DATABASE $DB_NAME OWNER $DB_USER;"
echo "✓ PostgreSQL database ready"
# 3. MySQL database setup
echo "Setting up MySQL database..."
mysql -u root -e "CREATE DATABASE IF NOT EXISTS $DB_NAME CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
mysql -u root -e "CREATE USER IF NOT EXISTS '$DB_USER'@'localhost' IDENTIFIED BY 'CHANGE_ME';"
mysql -u root -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost';"
mysql -u root -e "FLUSH PRIVILEGES;"
echo "✓ MySQL database ready"
# 4. Application directory
mkdir -p "$APP_DIR"
@@ -64,7 +63,7 @@ systemctl start "$APP_NAME"
echo "✓ Systemd service active"
# 8. Nginx config
cp deploy/nginx.conf /etc/nginx/sites-available/$APP_NAME
cp deploy/nginx.conf.example /etc/nginx/sites-available/$APP_NAME
ln -sf /etc/nginx/sites-available/$APP_NAME /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
echo "✓ Nginx configured"