1
0
forked from bot/app

🐛 修复无法重启进程的问题(未启动生命监视器)

This commit is contained in:
远野千束 2024-08-16 02:56:50 +08:00
parent 9b07d41f86
commit adc9b76688
8 changed files with 102 additions and 33 deletions

View File

@ -27,7 +27,7 @@ SYNC_FILTER_FUNC: TypeAlias = Callable[[Any], bool]
ASYNC_FILTER_FUNC: TypeAlias = Callable[[Any], Awaitable[bool]] ASYNC_FILTER_FUNC: TypeAlias = Callable[[Any], Awaitable[bool]]
FILTER_FUNC: TypeAlias = SYNC_FILTER_FUNC | ASYNC_FILTER_FUNC FILTER_FUNC: TypeAlias = SYNC_FILTER_FUNC | ASYNC_FILTER_FUNC
IS_MAIN_PROCESS = multiprocessing.current_process().name == "MainProcess"
_channel: dict[str, "Channel"] = {} _channel: dict[str, "Channel"] = {}
_callback_funcs: dict[str, ON_RECEIVE_FUNC] = {} _callback_funcs: dict[str, ON_RECEIVE_FUNC] = {}

View File

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
"""
共享内存模块类似于redis但是更加轻量级
"""
memory_database = {}
def set_memory(key: str, value: any) -> None:
pass
def get_mem_data(key: str) -> any:
pass

View File

@ -87,6 +87,8 @@ class ProcessManager:
else: else:
logger.warning("Unknown data received, ignored.") logger.warning("Unknown data received, ignored.")
_start_monitor()
def start_all(self): def start_all(self):
""" """
启动所有进程 启动所有进程

View File

@ -4,11 +4,13 @@
""" """
import asyncio import asyncio
import inspect import inspect
import multiprocessing
from pathlib import Path from pathlib import Path
from typing import Any, Callable, Coroutine from typing import Any, Callable, Coroutine
from liteyuki.log import logger from liteyuki.log import logger
IS_MAIN_PROCESS = multiprocessing.current_process().name == "MainProcess"
def is_coroutine_callable(call: Callable[..., Any]) -> bool: def is_coroutine_callable(call: Callable[..., Any]) -> bool:
""" """

View File

@ -11,38 +11,38 @@ license = "MIT & LSO"
package-mode = false package-mode = false
[tool.poetry.dependencies] #[tool.poetry.dependencies]
python = "^3.10" #python = "^3.10"
aiofiles = "~23.2.1" #aiofiles = "~23.2.1"
aiohttp = "~3.9.3" #aiohttp = "~3.9.3"
aiosqlite3 = "~0.3.0" #aiosqlite3 = "~0.3.0"
colored = "~2.2.4" #colored = "~2.2.4"
fastapi = "~0.110.0" #fastapi = "~0.110.0"
GitPython = "~3.1.42" #GitPython = "~3.1.42"
httpx = "~0.27.0" #httpx = "~0.27.0"
importlib_metadata = "~7.0.2" #importlib_metadata = "~7.0.2"
jieba = "~0.42.1" #jieba = "~0.42.1"
loguru = "~0.7.2" #loguru = "~0.7.2"
nb-cli = "~1.4.1" #nb-cli = "~1.4.1"
nonebot-adapter-onebot = "~2.4.3" #nonebot-adapter-onebot = "~2.4.3"
nonebot-adapter-satori = "~0.11.5" #nonebot-adapter-satori = "~0.11.5"
nonebot-plugin-alconna = "~0.46.3" #nonebot-plugin-alconna = "~0.46.3"
nonebot-plugin-apscheduler = "~0.4.0" #nonebot-plugin-apscheduler = "~0.4.0"
nonebot-plugin-htmlrender = "~0.3.1" #nonebot-plugin-htmlrender = "~0.3.1"
nonebot2 = { version = "~2.3.0", extras = ["fastapi", "httpx", "websockets"] } #nonebot2 = { version = "~2.3.0", extras = ["fastapi", "httpx", "websockets"] }
numpy = "~2.0.0" #numpy = "~2.0.0"
packaging = "~23.1" #packaging = "~23.1"
psutil = "~5.9.8" #psutil = "~5.9.8"
py-cpuinfo = "~9.0.0" #py-cpuinfo = "~9.0.0"
pydantic = "~2.7.0" #pydantic = "~2.7.0"
Pygments = "~2.17.2" #Pygments = "~2.17.2"
python-dotenv = "~1.0.1" #python-dotenv = "~1.0.1"
pytest = "~8.3.1" #pytest = "~8.3.1"
pytz = "~2024.1" #pytz = "~2024.1"
PyYAML = "~6.0.1" #PyYAML = "~6.0.1"
requests = "~2.31.0" #requests = "~2.31.0"
starlette = "~0.36.3" #starlette = "~0.36.3"
watchdog = "~4.0.0" #watchdog = "~4.0.0"
[[tool.poetry.source]] [[tool.poetry.source]]

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/15 下午11:29
@Author : snowykami
@Email : snowykami@outlook.com
@File : __init__.py.py
@Software: PyCharm
"""
from liteyuki.plugin import PluginMetadata
from .divided_by_lifespan import *
__plugin_mata__ = PluginMetadata(
name="计划任务",
description="计划任务插件,一些杂项任务的计划执行。",
)

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/15 下午11:32
@Author : snowykami
@Email : snowykami@outlook.com
@File : __init__.py
@Software: PyCharm
"""

View File

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/15 下午11:32
@Author : snowykami
@Email : snowykami@outlook.com
@File : after_start.py
@Software: PyCharm
"""
import time
from liteyuki import get_bot
liteyuki = get_bot()
@liteyuki.on_after_start
def save_startup_timestamp():
"""
储存启动的时间戳
"""
startup_timestamp = time.time()