Download Backend/pyrofork/plugins/restart.py from dhyeye/streamio: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/dhyeye/streamio/resolve/main/Backend/pyrofork/plugins/restart.py
- Command line
-
hf download hf://spaces/dhyeye/streamio/Backend/pyrofork/plugins/restart.py
-
curl -L -o restart.py https://huggingface.co/spaces/dhyeye/streamio/resolve/main/Backend/pyrofork/plugins/restart.py
1.45 kB
| import shutil | |
| from asyncio import create_subprocess_exec, gather | |
| from os import execl as osexecl | |
| from aiofiles import open as aiopen | |
| from pyrogram import Client, enums, filters | |
| from pyrogram.types import Message | |
| from Backend.helper.custom_filter import CustomFilters | |
| from Backend.logger import LOGGER | |
| #----- Owner-only /restart: run updater then re-exec the app via uv | |
| async def restart(client: Client, message: Message): | |
| try: | |
| restart_message = await message.reply_text( | |
| '<blockquote>⚙️ Restarting Backend API... \n\n✨ Please wait as we bring everything back online! 🚀</blockquote>', | |
| quote=True, | |
| parse_mode=enums.ParseMode.HTML | |
| ) | |
| proc1 = await create_subprocess_exec('uv', 'run', 'update.py') | |
| await gather(proc1.wait()) | |
| async with aiopen(".restartmsg", "w") as f: | |
| await f.write(f"{restart_message.chat.id}\n{restart_message.id}\n") | |
| LOGGER.info("Restarting the bot using uv package manager...") | |
| uv_path = shutil.which("uv") | |
| if not uv_path: | |
| raise RuntimeError("uv not found in PATH.") | |
| osexecl(uv_path, uv_path, "run", "-m", "Backend") | |
| except Exception as e: | |
| LOGGER.error(f"Error during restart: {e}") | |
| await message.reply_text("**❌ Failed to restart. Check logs for details.**") | |