Add supervisor configuration and database directory creation
This commit is contained in:
parent
faaeb0128b
commit
95f488310b
5
main.py
5
main.py
@ -1,10 +1,15 @@
|
|||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from app.database import engine
|
from app.database import engine
|
||||||
from app.models import Base
|
from app.models import Base
|
||||||
from app.routers import users_router
|
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
|
# Create database tables
|
||||||
Base.metadata.create_all(bind=engine)
|
Base.metadata.create_all(bind=engine)
|
||||||
|
|
||||||
|
11
run.sh
Executable file
11
run.sh
Executable file
@ -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
|
12
supervisor.conf
Normal file
12
supervisor.conf
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user