Files
edict/start.sh
cft0808 74d8130391 feat: Week 0-4 optimizations - event bus, state machine, dispatch, outbox relay
- EventBus: Redis Streams pub/sub for decoupled service communication
- State machine: strict lifecycle transitions with audit logging
- Dispatch worker: parallel execution, retry with backoff, resource locking
- Orchestrator: DAG-based task decomposition and dependency resolution
- Outbox relay: transactional outbox pattern for reliable event delivery
- Auth: dashboard authentication module
- Agent groups: sansheng/liubu agent configuration
- CI/CD: Docker publish workflow, systemd service, start script
- Frontend: dashboard build assets
- Tests: state machine consistency tests
2026-04-04 12:16:32 +08:00

79 lines
3.0 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# ══════════════════════════════════════════════════════════════
# 三省六部 · 一键启动脚本
# 同时启动看板服务器 + 数据刷新循环
# ══════════════════════════════════════════════════════════════
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$REPO_DIR"
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
# 检查 Python
if ! command -v python3 &>/dev/null; then
echo -e "${RED}❌ 未找到 python3请先安装 Python 3.9+${NC}"
exit 1
fi
# 确保 data 目录存在
mkdir -p "$REPO_DIR/data"
# 初始化必需的数据文件(如果不存在)
for f in live_status.json agent_config.json model_change_log.json sync_status.json; do
[ ! -f "$REPO_DIR/data/$f" ] && echo '{}' > "$REPO_DIR/data/$f"
done
[ ! -f "$REPO_DIR/data/pending_model_changes.json" ] && echo '[]' > "$REPO_DIR/data/pending_model_changes.json"
[ ! -f "$REPO_DIR/data/tasks_source.json" ] && echo '[]' > "$REPO_DIR/data/tasks_source.json"
[ ! -f "$REPO_DIR/data/tasks.json" ] && echo '[]' > "$REPO_DIR/data/tasks.json"
[ ! -f "$REPO_DIR/data/officials.json" ] && echo '[]' > "$REPO_DIR/data/officials.json"
[ ! -f "$REPO_DIR/data/officials_stats.json" ] && echo '{}' > "$REPO_DIR/data/officials_stats.json"
cleanup() {
echo ""
echo -e "${YELLOW}正在关闭服务...${NC}"
kill $SERVER_PID $LOOP_PID 2>/dev/null
wait $SERVER_PID $LOOP_PID 2>/dev/null
echo -e "${GREEN}✅ 已关闭${NC}"
exit 0
}
trap cleanup SIGINT SIGTERM
echo ""
echo -e "${BLUE}╔══════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ 🏛️ 三省六部 · 服务启动中 ║${NC}"
echo -e "${BLUE}╚══════════════════════════════════════════╝${NC}"
echo ""
# 启动数据刷新循环(后台)
if command -v openclaw &>/dev/null; then
echo -e "${GREEN}▶ 启动数据刷新循环...${NC}"
bash scripts/run_loop.sh &
LOOP_PID=$!
else
echo -e "${YELLOW}⚠️ 未检测到 OpenClaw CLI跳过数据刷新循环${NC}"
echo -e "${YELLOW} 看板将以只读模式运行(使用已有数据)${NC}"
LOOP_PID=""
fi
# 启动看板服务器
echo -e "${GREEN}▶ 启动看板服务器...${NC}"
python3 dashboard/server.py &
SERVER_PID=$!
sleep 1
echo ""
echo -e "${GREEN}✅ 服务已启动!${NC}"
echo -e " 看板地址: ${BLUE}http://127.0.0.1:7891${NC}"
echo -e "${YELLOW}Ctrl+C${NC} 关闭所有服务"
echo ""
# 尝试自动打开浏览器
if command -v open &>/dev/null; then
open http://127.0.0.1:7891
elif command -v xdg-open &>/dev/null; then
xdg-open http://127.0.0.1:7891
fi
# 等待任一进程退出
wait $SERVER_PID $LOOP_PID 2>/dev/null