From 493b7c2d2483ed9608038f281ac4bdf6245f933f Mon Sep 17 00:00:00 2001 From: thsrite Date: Sat, 14 Oct 2023 20:49:03 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E9=87=8D=E5=90=AF=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chain/system.py | 10 ++++++++++ app/command.py | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/chain/system.py b/app/chain/system.py index 126ef865..75c0ab98 100644 --- a/app/chain/system.py +++ b/app/chain/system.py @@ -2,12 +2,14 @@ from typing import Union from app.chain import ChainBase from app.schemas import Notification, MessageChannel +from app.utils.system import SystemUtils class SystemChain(ChainBase): """ 系统级处理链 """ + def remote_clear_cache(self, channel: MessageChannel, userid: Union[int, str]): """ 清理系统缓存 @@ -15,3 +17,11 @@ class SystemChain(ChainBase): self.clear_cache() self.post_message(Notification(channel=channel, title=f"缓存清理完成!", userid=userid)) + + def restart(self, channel: MessageChannel, userid: Union[int, str]): + """ + 重启系统 + """ + self.post_message(Notification(channel=channel, + title=f"系统正在重启,请耐心等候!", userid=userid)) + SystemUtils.restart() diff --git a/app/command.py b/app/command.py index dc903873..e4b5a1f8 100644 --- a/app/command.py +++ b/app/command.py @@ -19,7 +19,6 @@ from app.schemas import Notification from app.schemas.types import EventType, MessageChannel from app.utils.object import ObjectUtils from app.utils.singleton import Singleton -from app.utils.system import SystemUtils class CommandChian(ChainBase): @@ -139,7 +138,7 @@ class Command(metaclass=Singleton): "data": {} }, "/restart": { - "func": SystemUtils.restart, + "func": SystemChain(self._db).restart, "description": "重启系统", "category": "管理", "data": {}