1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

Проверка

This commit is contained in:
MoonTestUse1
2024-12-28 05:32:33 +06:00
commit f9543463c4
84 changed files with 6811 additions and 0 deletions

38
backend/run.py Normal file
View File

@@ -0,0 +1,38 @@
"""
Main application entry point.
Runs both the FastAPI application and Telegram bot.
"""
import asyncio
import uvicorn
from app.main import app
from app.bot import start_bot
from logging import getLogger
logger = getLogger(__name__)
async def run_api():
"""Run FastAPI application"""
config = uvicorn.Config(
app,
host="0.0.0.0",
port=8000,
reload=True
)
server = uvicorn.Server(config)
await server.serve()
async def main():
"""Run both bot and API in the main thread"""
try:
# Создаем задачи для бота и API
bot_task = asyncio.create_task(start_bot())
api_task = asyncio.create_task(run_api())
# Запускаем обе задачи
await asyncio.gather(bot_task, api_task)
except Exception as e:
logger.error(f"Application crashed: {e}", exc_info=True)
if __name__ == "__main__":
# Запускаем в основном потоке
asyncio.run(main())