diff --git a/main.py b/main.py index c5b9cc4..2efd1d0 100644 --- a/main.py +++ b/main.py @@ -1,10 +1,15 @@ from fastapi import FastAPI import uvicorn +from pathlib import Path from app.database import engine from app.models import Base from app.routers import users_router +# Create database directory (won't error if it already exists) +DB_DIR = Path("/app") / "storage" / "db" +DB_DIR.mkdir(parents=True, exist_ok=True) + # Create database tables Base.metadata.create_all(bind=engine) diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..2c1d035 --- /dev/null +++ b/run.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Run script for FastAPI application + +# Navigate to the project directory (using the actual path) +cd /projects/genericrestapiservice-w33054 + +# Create storage directory if it doesn't exist +mkdir -p /app/storage/db + +# Run the app with uvicorn +exec uvicorn main:app --host 0.0.0.0 --port 8001 \ No newline at end of file diff --git a/supervisor.conf b/supervisor.conf new file mode 100644 index 0000000..36a20ae --- /dev/null +++ b/supervisor.conf @@ -0,0 +1,12 @@ +[program:app-8001] +command=/projects/genericrestapiservice-w33054/run.sh +directory=/projects/genericrestapiservice-w33054 +autostart=true +autorestart=true +startsecs=5 +stopwaitsecs=5 +redirect_stderr=true +stdout_logfile=/var/log/app-8001.log +stdout_logfile_maxbytes=10MB +stdout_logfile_backups=5 +user=appuser \ No newline at end of file