diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..3ab1912 --- /dev/null +++ b/start.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +echo "🚀 启动多智能体任务管理系统..." + +# 检查 Docker 是否在运行 +if ! docker info > /dev/null 2>&1; then + echo "❌ Docker 未运行,请先启动 Docker" + exit 1 +fi + +# 停止并清理旧容器 +echo "清理旧容器..." +docker stop test-postgres 2>/dev/null || true +docker rm test-postgres 2>/dev/null || true + +# 启动 PostgreSQL +echo "启动 PostgreSQL..." +docker run -d \ + --name agent-task-postgres \ + --restart unless-stopped \ + -e POSTGRES_DB=agent_tasks \ + -e POSTGRES_USER=postgres \ + -e POSTGRES_PASSWORD=postgres \ + -p 5432:5432 \ + postgres:15-alpine + +# 等待数据库就绪 +echo "等待数据库启动..." +sleep 5 + +# 启动应用服务 +echo "启动应用服务..." +pkill -f "node.*server-postgres.js" || true +cd "$(dirname "$0")" +DB_HOST=localhost \ +DB_PORT=5432 \ +DB_PASSWORD=postgres \ +nohup node server-postgres.js > server.log 2>&1 & + +sleep 2 + +# 检查服务状态 +if curl -s http://localhost:3000/health > /dev/null; then + echo "" + echo "✅ 服务启动成功!" + echo "" + echo "🌐 Web 界面: http://localhost:3000" + echo "📡 API 地址: http://localhost:3000/api" + echo "📊 健康检查: http://localhost:3000/health" + echo "" + echo "📝 查看日志: tail -f server.log" + echo "🛑 停止服务: ./stop.sh" +else + echo "❌ 服务启动失败,请查看 server.log" + exit 1 +fi diff --git a/stop.sh b/stop.sh new file mode 100755 index 0000000..16c41fb --- /dev/null +++ b/stop.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +echo "🛑 停止多智能体任务管理系统..." + +# 停止 Node.js 服务 +pkill -f "node.*server-postgres.js" + +# 停止 PostgreSQL 容器 +docker stop agent-task-postgres 2>/dev/null +docker rm agent-task-postgres 2>/dev/null + +echo "✅ 服务已停止"