mirror of
https://github.com/MichaByte/OnBoard-Live.git
synced 2025-12-06 08:33:40 -05:00
more WIP docker stuff
This commit is contained in:
parent
e75f8c944a
commit
8747a8ffe3
7 changed files with 44 additions and 15 deletions
|
|
@ -12,10 +12,12 @@ RUN apt-get install -y python3-opencv
|
|||
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY main.py schema.prisma .
|
||||
COPY schema.prisma .
|
||||
|
||||
COPY migrations .
|
||||
ADD migrations .
|
||||
|
||||
RUN prisma generate
|
||||
|
||||
COPY main.py .
|
||||
|
||||
CMD [ "fastapi", "run", "main.py" ]
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from contextlib import asynccontextmanager
|
|||
from datetime import datetime
|
||||
from secrets import choice, token_hex
|
||||
from typing import Dict, List
|
||||
import time
|
||||
|
||||
import cv2
|
||||
import httpx
|
||||
|
|
@ -151,12 +152,6 @@ async def check_for_new():
|
|||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
await update_active()
|
||||
scheduler.start()
|
||||
scheduler.add_job(update_active, IntervalTrigger(minutes=5))
|
||||
scheduler.add_job(check_for_new, IntervalTrigger(seconds=3))
|
||||
scheduler.add_job(rotate_fernet_key, IntervalTrigger(minutes=30))
|
||||
await rotate_fernet_key()
|
||||
await db.connect()
|
||||
async with httpx.AsyncClient() as client:
|
||||
for stream in await db.stream.find_many():
|
||||
|
|
@ -164,6 +159,11 @@ async def lifespan(app: FastAPI):
|
|||
f"http://{os.environ['MEDIAMTX_IP']}:9997/v3/config/paths/add/" + stream.key,
|
||||
json={"name": stream.key},
|
||||
)
|
||||
scheduler.start()
|
||||
scheduler.add_job(update_active, IntervalTrigger(minutes=5))
|
||||
scheduler.add_job(check_for_new, IntervalTrigger(seconds=3))
|
||||
scheduler.add_job(rotate_fernet_key, IntervalTrigger(minutes=30))
|
||||
await rotate_fernet_key()
|
||||
yield
|
||||
scheduler.shutdown()
|
||||
await db.disconnect()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ generator client {
|
|||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
provider = "sqlite"
|
||||
url = "file:./db/dev.db"
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue