Dvs / main.py
Muttered3's picture
Update main.py
45ef928 verified
raw
history blame
812 Bytes
import asyncio
import os
from dummy_server import run_server
from bot import app
from worker import manage_workers
from pyrogram import idle
async def main():
# 1. Start the dummy web server so Hugging Face keeps the Space awake on port 7860
print("🌐 Starting Dummy Server...")
asyncio.create_task(run_server())
# 2. Start the Pyrogram Bot
print("πŸ€– Starting Pyrogram Bot...")
await app.start()
# 3. Start the Sniper Worker Manager (Redis-Free version)
print("πŸš€ Firing up Sniper Workers...")
asyncio.create_task(manage_workers())
# 4. Keep the process alive forever
await idle()
# Cleanup on shutdown
await app.stop()
if __name__ == "__main__":
# Pyrogram's app.run() handles the async event loop perfectly
app.run(main())