feat: 增强插件管理和日志处理,兼容旧版参数,优化 UDS 路径处理
This commit is contained in:
@@ -18,6 +18,11 @@ class UDSConnection(Connection):
|
||||
pass # 直接复用 Connection 基类的分帧读写
|
||||
|
||||
|
||||
# Unix domain socket 路径的系统限制(sun_path 字段长度)
|
||||
# Linux: 108 字节, macOS: 104 字节
|
||||
_UDS_PATH_MAX = 104
|
||||
|
||||
|
||||
class UDSTransportServer(TransportServer):
|
||||
"""UDS 传输服务端"""
|
||||
|
||||
@@ -26,6 +31,16 @@ class UDSTransportServer(TransportServer):
|
||||
# 默认放在临时目录,使用 uuid 确保同一进程多实例不碰撞
|
||||
import uuid
|
||||
socket_path = os.path.join(tempfile.gettempdir(), f"maibot-plugin-{os.getpid()}-{uuid.uuid4().hex[:8]}.sock")
|
||||
|
||||
# 如果路径超出 UDS 限制,回退到更短的路径
|
||||
if len(socket_path.encode()) > _UDS_PATH_MAX:
|
||||
socket_path = os.path.join("/tmp", f"mb-{os.getpid()}-{uuid.uuid4().hex[:8]}.sock")
|
||||
|
||||
if len(socket_path.encode()) > _UDS_PATH_MAX:
|
||||
raise OSError(
|
||||
f"UDS socket 路径过长 ({len(socket_path.encode())} > {_UDS_PATH_MAX} 字节): {socket_path}"
|
||||
)
|
||||
|
||||
self._socket_path = socket_path
|
||||
self._server: Optional[asyncio.AbstractServer] = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user