Initial commit: SenSu Alpha 0.2.0
- 13-service async plugin framework - Textual TUI with CLI fallback - Plugin hot-reload + permission system - Web management panel (aiohttp) - Bridge-based inter-module communication - 10 regression tests Fixes applied: - PBKDF2-SHA256 auth (was plain SHA256) - Auth bypass removed (was allow-all on fail) - Bare excepts replaced with logged errors - CatFramework/DreamSu -> SenSu naming unified - ServiceManager: health checks + startup_order - Env var credentials (SENSU_ADMIN_PASSWORD etc)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import time
|
||||
from aiohttp import web
|
||||
from ..utils.auth import panel_auth
|
||||
from ..utils.system_info import SystemInfoCollector
|
||||
|
||||
collector = SystemInfoCollector()
|
||||
|
||||
def setup_routes(app, prefix=''):
|
||||
app.router.add_get(f'{prefix}/api/framework', panel_auth(get_framework))
|
||||
app.router.add_get(f'{prefix}/api/system', panel_auth(get_system))
|
||||
|
||||
async def get_framework(req):
|
||||
sm = req.app.get('service_manager')
|
||||
if not sm: return web.json_response({"error": "Missing"}, 500)
|
||||
|
||||
ps = sm.get_service("plugin")
|
||||
# 🟢 修复:使用 sm.start_time 属性
|
||||
uptime = time.time() - getattr(sm, 'start_time', time.time())
|
||||
|
||||
return web.json_response({
|
||||
"version": "Alpha_0.2.0",
|
||||
"uptime": int(uptime), # 取整秒
|
||||
"plugins": len(ps.plugins) if ps else 0
|
||||
})
|
||||
|
||||
async def get_system(req):
|
||||
return web.json_response(collector.get_all())
|
||||
Reference in New Issue
Block a user