mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
Починка статусов в ботов4
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
"""
|
||||
Main application entry point.
|
||||
Runs both the FastAPI application and Telegram bot.
|
||||
"""
|
||||
import asyncio
|
||||
import uvicorn
|
||||
from app.main import app
|
||||
@@ -6,30 +10,25 @@ from logging import getLogger
|
||||
|
||||
logger = getLogger(__name__)
|
||||
|
||||
|
||||
async def run_bot():
|
||||
"""Run Telegram bot"""
|
||||
print("Bot started")
|
||||
# try:
|
||||
# await start_bot()
|
||||
# except Exception as e:
|
||||
# logger.error(f"Bot crashed: {e}", exc_info=True)
|
||||
|
||||
try:
|
||||
await start_bot()
|
||||
except Exception as e:
|
||||
logger.error(f"Bot crashed: {e}", exc_info=True)
|
||||
|
||||
async def run_api():
|
||||
"""Run FastAPI application"""
|
||||
config = uvicorn.Config(app, host=["0.0.0.0"], port=8000, reload=True)
|
||||
config = uvicorn.Config(app, host="0.0.0.0", port=8000, reload=True)
|
||||
server = uvicorn.Server(config)
|
||||
try:
|
||||
await server.serve()
|
||||
except Exception as e:
|
||||
logger.error(f"API crashed: {e}", exc_info=True)
|
||||
|
||||
|
||||
async def run_all():
|
||||
"""Run both bot and API"""
|
||||
await asyncio.gather(run_bot(), run_api())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(run_all())
|
||||
asyncio.run(run_all())
|
Reference in New Issue
Block a user