mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-10-21 16:27:15 +08:00
🐛 修复安装了某些nb插件时重启
命令报错问题#390
This commit is contained in:
parent
437048cfed
commit
c59b0fad67
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import asyncio
|
||||
import contextlib
|
||||
import random
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@ -138,10 +139,14 @@ async def _(bot: Bot, event: MessageEvent):
|
||||
)
|
||||
await asyncio.sleep(0.25)
|
||||
save_json(reboot_data, Path() / 'rebooting.json')
|
||||
with contextlib.suppress(Exception):
|
||||
await get_app().router.shutdown()
|
||||
if sys.argv[0].endswith('nb'):
|
||||
sys.argv[0] = 'bot.py'
|
||||
os.execv(sys.executable, [sys.executable] + sys.argv)
|
||||
reboot_arg = (
|
||||
[sys.executable] + sys.argv
|
||||
if sys.argv[0].endswith('.py')
|
||||
else [sys.executable, 'bot.py']
|
||||
)
|
||||
os.execv(sys.executable, reboot_arg)
|
||||
|
||||
|
||||
@run_cmd.handle()
|
||||
|
@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
import contextlib
|
||||
import datetime
|
||||
import os
|
||||
import sys
|
||||
@ -136,7 +137,11 @@ async def bot_restart():
|
||||
{'session_type': 'private', 'session_id': SUPERUSERS[0]},
|
||||
Path() / 'rebooting.json',
|
||||
)
|
||||
with contextlib.suppress(Exception):
|
||||
await get_app().router.shutdown()
|
||||
if sys.argv[0].endswith('nb'):
|
||||
sys.argv[0] = 'bot.py'
|
||||
os.execv(sys.executable, [sys.executable] + sys.argv)
|
||||
reboot_arg = (
|
||||
[sys.executable] + sys.argv
|
||||
if sys.argv[0].endswith('.py')
|
||||
else [sys.executable, 'bot.py']
|
||||
)
|
||||
os.execv(sys.executable, reboot_arg)
|
||||
|
Loading…
Reference in New Issue
Block a user