优化 local 模式兼容性与部署可靠性
- SQL 方言层:agent updated_at、dashboard 小时分桶、清理任务跨 SQLite/MySQL - Cache Capabilities:redka 跳过 ZSet/PubSub,Agent 聚合改 DB 直读 - local 模式 redka 初始化失败 Fatal;/version 返回 features - SQLite WAL + 连接池限制;K8s data 改 PVC 持久化 - run.sh:旧参数迁移、升级后 /version 校验
This commit is contained in:
1 parent
1f4f63cf6e
commit
b7166acda4
13 files changed
+374
-152
No files matched your search
@@ -451,7 +451,38 @@ save_binary_args() {
|
||||
printf '%s\n' "$@" > "$BINARY_ARGS_FILE"
|
||||
}
|
||||
|
||||
# 将旧版 --db-driver sqlite 参数迁移为 --mode local // Logan.Li
|
||||
migrate_binary_args_file() {
|
||||
[ -f "$BINARY_ARGS_FILE" ] || return 0
|
||||
if grep -qE '^--mode ' "$BINARY_ARGS_FILE" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
if ! grep -qE '^--db-driver' "$BINARY_ARGS_FILE" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
local port="8080"
|
||||
local lines=()
|
||||
while IFS= read -r line || [ -n "$line" ]; do
|
||||
[ -n "$line" ] && lines+=("$line")
|
||||
done < "$BINARY_ARGS_FILE"
|
||||
local i=0
|
||||
while [ $i -lt ${#lines[@]} ]; do
|
||||
if [ "${lines[$i]}" = "--port" ] && [ $((i + 1)) -lt ${#lines[@]} ]; then
|
||||
port="${lines[$((i + 1))]}"
|
||||
break
|
||||
fi
|
||||
if [[ "${lines[$i]}" == --port=* ]]; then
|
||||
port="${lines[$i]#--port=}"
|
||||
break
|
||||
fi
|
||||
i=$((i + 1))
|
||||
done
|
||||
info "迁移启动参数: --db-driver → --mode local --port $port"
|
||||
save_binary_args --mode local --port "$port"
|
||||
}
|
||||
|
||||
load_binary_args() {
|
||||
migrate_binary_args_file
|
||||
local -n _out=$1
|
||||
_out=()
|
||||
if [ -f "$BINARY_ARGS_FILE" ]; then
|
||||
@@ -464,6 +495,21 @@ load_binary_args() {
|
||||
fi
|
||||
}
|
||||
|
||||
# 升级后校验 /version 驱动信息 // Logan.Li
|
||||
verify_binary_version() {
|
||||
local port=${1:-8080}
|
||||
local body
|
||||
body=$(curl -sf "http://localhost:${port}/version" 2>/dev/null) || {
|
||||
warning "/version 未响应"
|
||||
return 1
|
||||
}
|
||||
info "版本探测: $body"
|
||||
echo "$body" | grep -q '"mode":"local"' && success "mode=local 已生效" || warning "mode 非 local"
|
||||
echo "$body" | grep -q '"db_driver":"sqlite"' && success "db_driver=sqlite 已生效" || true
|
||||
echo "$body" | grep -q '"redis_driver":"redka"' && success "redis_driver=redka 已生效" || true
|
||||
return 0
|
||||
}
|
||||
|
||||
binary_listen_port() {
|
||||
local args=("$@")
|
||||
local i=0
|
||||
@@ -492,7 +538,7 @@ start_binary_daemon() {
|
||||
if wait_binary_ready "$port"; then
|
||||
success "二进制已启动 (PID: $(cat "$BINARY_PID_FILE"), 端口: $port)"
|
||||
info "日志: $BACKEND_DIR/logs/aiops.log"
|
||||
info "健康检查: http://localhost:${port}/version"
|
||||
verify_binary_version "$port" || true
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
@@ -896,6 +942,9 @@ cmd_kubernetes() {
|
||||
kubectl apply -f "$KUBERNETES_MANIFEST_DIR/secret.yaml"
|
||||
kubectl apply -f "$KUBERNETES_MANIFEST_DIR/configmap.yaml"
|
||||
|
||||
info "部署 local 模式数据卷 (PVC)..."
|
||||
kubectl apply -f "$KUBERNETES_MANIFEST_DIR/pvc-aiops-data.yaml"
|
||||
|
||||
info "部署 MySQL + Redis..."
|
||||
kubectl apply -f "$KUBERNETES_MANIFEST_DIR/mysql.yaml"
|
||||
kubectl apply -f "$KUBERNETES_MANIFEST_DIR/redis.yaml"
|
||||
|
||||
Reference in new issue
Block a user