Spaces:
Paused
Paused
| 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()) |