diff --git a/sage.service b/sage.service new file mode 100644 index 0000000..8c36727 --- /dev/null +++ b/sage.service @@ -0,0 +1,16 @@ +[Unit] +Wants=systemd-networkd.service + +[Service] +User=hermesai +Group=hermesai +Type=forking +WorkingDirectory=/home/hermesai/repos/sage +ExecStart=/home/hermesai/repos/sage/start.sh +ExecStop=/home/hermesai/repos/sage/stop.sh +StandardOutput=append:/var/log/sage/sage.log +StandardError=append:/var/log/sage/sage.log +SyslogIdentifier=sage + +[Install] +WantedBy=multi-user.target diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..02a5c99 --- /dev/null +++ b/start.sh @@ -0,0 +1,4 @@ +#!/usr/bin/bash +cd /home/hermesai/repos/sage +/home/hermesai/repos/sage/py3/bin/python /home/hermesai/repos/sage/app/sage.py -p 9180 -w /home/hermesai/repos/sage & +exit 0 diff --git a/stop.sh b/stop.sh index 0f95ae5..61a513c 100755 --- a/stop.sh +++ b/stop.sh @@ -1,115 +1,2 @@ -#!/bin/bash -# Sage Web Application Stop Script -# 停止所有 Web Workers 和独立后台程序 - -set -e - -# 切换到脚本所在目录 -cd "$(dirname "$0")" - -WORKDIR="$(pwd)" -PIDFILE="$WORKDIR/sage.pid" -BINPIDFILE="$WORKDIR/sage_backend.pid" - -echo "=========================================" -echo "停止 Sage Web Application" -echo "=========================================" - -# ========================================= -# 步骤 1: 停止 Web Workers -# ========================================= -echo "" -echo "--- 停止 Web Workers ---" - -if [ -f "$PIDFILE" ]; then - echo "读取 Worker PID 文件..." - - while IFS= read -r pid || [ -n "$pid" ]; do - pid=$(echo "$pid" | tr -d '[:space:]') - [ -z "$pid" ] && continue - - if kill -0 "$pid" 2>/dev/null; then - echo "正在停止 Worker (PID: $pid) ..." - kill "$pid" 2>/dev/null || true - else - echo "Worker (PID: $pid) 已不在运行" - fi - done < "$PIDFILE" - - # 等待进程退出 - echo "等待服务关闭..." - for i in $(seq 1 10); do - all_stopped=true - while IFS= read -r pid || [ -n "$pid" ]; do - pid=$(echo "$pid" | tr -d '[:space:]') - [ -z "$pid" ] && continue - if kill -0 "$pid" 2>/dev/null; then - all_stopped=false - break - fi - done < "$PIDFILE" - - if $all_stopped; then - echo "所有 Worker 已停止 (用时 ${i}s)" - break - fi - sleep 1 - done - - # 强制杀死仍在运行的进程 - while IFS= read -r pid || [ -n "$pid" ]; do - pid=$(echo "$pid" | tr -d '[:space:]') - [ -z "$pid" ] && continue - if kill -0 "$pid" 2>/dev/null; then - echo "强制停止 Worker (PID: $pid)" - kill -9 "$pid" 2>/dev/null || true - fi - done < "$PIDFILE" - - # 清理 PID 文件 - rm -f "$PIDFILE" -else - echo "未找到 Worker PID 文件 ($PIDFILE)" -fi - -# ========================================= -# 步骤 2: 停止独立后台程序 -# ========================================= -echo "" -echo "--- 停止独立后台程序 ---" - -if [ -f "$BINPIDFILE" ]; then - echo "读取后台程序 PID 文件..." - - while IFS= read -r line || [ -n "$line" ]; do - line=$(echo "$line" | tr -d '[:space:]') - [ -z "$line" ] && continue - - # 格式: name:pid - name="${line%%:*}" - pid="${line##*:}" - - if kill -0 "$pid" 2>/dev/null; then - echo "正在停止 $name (PID: $pid) ..." - kill "$pid" 2>/dev/null || true - sleep 1 - if kill -0 "$pid" 2>/dev/null; then - echo "强制停止 $name (PID: $pid)" - kill -9 "$pid" 2>/dev/null || true - fi - echo " -> $name 已停止" - else - echo "$name (PID: $pid) 已不在运行" - fi - done < "$BINPIDFILE" - - # 清理 PID 文件 - rm -f "$BINPIDFILE" -else - echo "未找到后台程序 PID 文件 ($BINPIDFILE)" -fi - -echo "" -echo "=========================================" -echo "所有服务已停止" -echo "=========================================" +PID=$(lsof -t -i:9180) +kill -9 $PID diff --git a/wwwroot/accounting b/wwwroot/accounting index 7ded735..04a78ff 120000 --- a/wwwroot/accounting +++ b/wwwroot/accounting @@ -1 +1 @@ -../pkgs/accounting/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/accounting/wwwroot \ No newline at end of file diff --git a/wwwroot/appbase b/wwwroot/appbase index 63a1cc7..e2fe645 120000 --- a/wwwroot/appbase +++ b/wwwroot/appbase @@ -1 +1 @@ -../pkgs/appbase/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/appbase/wwwroot \ No newline at end of file diff --git a/wwwroot/charge b/wwwroot/charge index 3a49949..cfa2b55 120000 --- a/wwwroot/charge +++ b/wwwroot/charge @@ -1 +1 @@ -../pkgs/charge/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/charge/wwwroot \ No newline at end of file diff --git a/wwwroot/dapi b/wwwroot/dapi index 4e3dcab..c7d9afb 120000 --- a/wwwroot/dapi +++ b/wwwroot/dapi @@ -1 +1 @@ -../pkgs/dapi/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/dapi/wwwroot \ No newline at end of file diff --git a/wwwroot/discount b/wwwroot/discount index 6a1ca3e..f9cbdf6 120000 --- a/wwwroot/discount +++ b/wwwroot/discount @@ -1 +1 @@ -../pkgs/discount/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/discount/wwwroot \ No newline at end of file diff --git a/wwwroot/filemgr b/wwwroot/filemgr index 70a473c..de3b622 120000 --- a/wwwroot/filemgr +++ b/wwwroot/filemgr @@ -1 +1 @@ -../pkgs/filemgr/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/filemgr/wwwroot \ No newline at end of file diff --git a/wwwroot/harnessed_agent b/wwwroot/harnessed_agent index 5b2bbe5..ba739cc 120000 --- a/wwwroot/harnessed_agent +++ b/wwwroot/harnessed_agent @@ -1 +1 @@ -../../harnessed_agent/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/harnessed_agent/wwwroot \ No newline at end of file diff --git a/wwwroot/harnessed_reasoning b/wwwroot/harnessed_reasoning index 75bcd3f..9063265 120000 --- a/wwwroot/harnessed_reasoning +++ b/wwwroot/harnessed_reasoning @@ -1 +1 @@ -../../harnessed_reasoning/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/harnessed_reasoning/wwwroot \ No newline at end of file diff --git a/wwwroot/index.ui b/wwwroot/index.ui index e06e91d..93c1380 100644 --- a/wwwroot/index.ui +++ b/wwwroot/index.ui @@ -1,18 +1,17 @@ { "widgettype": "VBox", "options": { + "css": "sage-shell", "width": "100%", - "height": "100%", - "bgcolor": "#0B1120" + "height": "100%" }, "subwidgets": [ { "widgettype": "HBox", "options": { + "css": "sage-topbar", "width": "100%", "height": "56px", - "bgcolor": "#111827", - "borderBottom": "1px solid #334155", "padding": "0 16px", "alignItems": "center" }, @@ -21,11 +20,8 @@ "widgettype": "Button", "id": "sidebar_toggle_btn", "options": { + "css": "sidebar-toggle", "label": "", - "bgcolor": "transparent", - "color": "#94A3B8", - "border": "1px solid #334155", - "borderRadius": "8px", "width": "36px", "height": "36px", "padding": "0" @@ -51,8 +47,8 @@ { "widgettype": "Title4", "options": { + "css": "sage-brand-title", "text": "Sage", - "color": "#F1F5F9", "fontWeight": "bold", "marginLeft": "8px" } @@ -64,11 +60,8 @@ "widgettype": "Button", "id": "theme_toggle_btn", "options": { + "css": "theme-toggle", "label": "", - "bgcolor": "transparent", - "color": "#94A3B8", - "border": "1px solid #334155", - "borderRadius": "50%", "width": "36px", "height": "36px", "padding": "0" @@ -126,10 +119,9 @@ "widgettype": "VBox", "id": "sage_sidebar", "options": { + "css": "sage-sidebar", "width": "240px", - "height": "100%", - "bgcolor": "#111827", - "borderRight": "1px solid #334155" + "height": "100%" }, "subwidgets": [ { @@ -160,7 +152,7 @@ "widgettype": "VBox", "id": "sage_main_content", "options": { - "css": "filler", + "css": "sage-main", "height": "100%", "padding": "24px" }, @@ -168,9 +160,9 @@ { "widgettype": "Text", "options": { + "css": "sage-text-secondary", "text": "加载中...", - "fontSize": "16px", - "color": "#94A3B8" + "fontSize": "16px" } } ] diff --git a/wwwroot/llmage b/wwwroot/llmage index d562baa..f6e66b3 120000 --- a/wwwroot/llmage +++ b/wwwroot/llmage @@ -1 +1 @@ -../pkgs/llmage/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/llmage/wwwroot \ No newline at end of file diff --git a/wwwroot/msp b/wwwroot/msp index b23a28e..cf5cfa6 120000 --- a/wwwroot/msp +++ b/wwwroot/msp @@ -1 +1 @@ -../pkgs/msp/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/msp/wwwroot \ No newline at end of file diff --git a/wwwroot/platformbiz b/wwwroot/platformbiz index c4a15a7..a47c2cb 120000 --- a/wwwroot/platformbiz +++ b/wwwroot/platformbiz @@ -1 +1 @@ -../pkgs/platformbiz/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/platformbiz/wwwroot \ No newline at end of file diff --git a/wwwroot/pricing b/wwwroot/pricing index 7eba1f1..75f4db4 120000 --- a/wwwroot/pricing +++ b/wwwroot/pricing @@ -1 +1 @@ -../pkgs/pricing/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/pricing/wwwroot \ No newline at end of file diff --git a/wwwroot/rag b/wwwroot/rag index f43d975..1ac33d3 120000 --- a/wwwroot/rag +++ b/wwwroot/rag @@ -1 +1 @@ -../pkgs/rag/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/rag/wwwroot \ No newline at end of file diff --git a/wwwroot/rbac b/wwwroot/rbac index d514a57..3f6c124 120000 --- a/wwwroot/rbac +++ b/wwwroot/rbac @@ -1 +1 @@ -../pkgs/rbac/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/rbac/wwwroot \ No newline at end of file diff --git a/wwwroot/reallife_asset b/wwwroot/reallife_asset new file mode 120000 index 0000000..6b7ee8c --- /dev/null +++ b/wwwroot/reallife_asset @@ -0,0 +1 @@ +/home/hermesai/repos/sage/pkgs/reallife_asset/wwwroot \ No newline at end of file diff --git a/wwwroot/supplychain b/wwwroot/supplychain index 4c4852c..1356a70 120000 --- a/wwwroot/supplychain +++ b/wwwroot/supplychain @@ -1 +1 @@ -../../supplychain/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/supplychain/wwwroot \ No newline at end of file diff --git a/wwwroot/uapi b/wwwroot/uapi index 5584ba3..5cb16d6 120000 --- a/wwwroot/uapi +++ b/wwwroot/uapi @@ -1 +1 @@ -../pkgs/uapi/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/uapi/wwwroot \ No newline at end of file diff --git a/wwwroot/unipay b/wwwroot/unipay index b019d95..4e2e2de 120000 --- a/wwwroot/unipay +++ b/wwwroot/unipay @@ -1 +1 @@ -../pkgs/unipay/wwwroot \ No newline at end of file +/home/hermesai/repos/sage/pkgs/unipay/wwwroot \ No newline at end of file