From 0ab3935679681e8101d48eb70424e4dbd5304562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=93=E7=AB=A5?= Date: Mon, 6 Apr 2026 09:02:21 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=83=A8=E7=BD=B2=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=20deploy.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 deploy.sh diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..4ab6299 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# OpenClaw Memory 部署脚本 +# 在宿主机运行 + +set -e + +echo "☯️ 开始部署 OpenClaw Memory 系统..." + +# 配置 +DEPLOY_DIR="/app/openclaw-memory" +DB_HOST="10.2.0.100" +DB_PORT="5432" +DB_USER="daotong" +DB_PASSWORD="825670@DaotongSql" +DB_NAME="daotong" +SERVICE_PORT="8087" + +# 检查目录 +if [ ! -d "$DEPLOY_DIR" ]; then + echo "❌ 部署目录不存在: $DEPLOY_DIR" + echo "请先克隆代码库:" + echo "git clone http://10.2.0.100:8989/daotong/openclaw-memory.git $DEPLOY_DIR" + exit 1 +fi + +cd "$DEPLOY_DIR/backend" + +# 配置环境变量 +cat > .env << EOF +DB_HOST=$DB_HOST +DB_PORT=$DB_PORT +DB_USER=$DB_USER +DB_PASSWORD=$DB_PASSWORD +DB_NAME=$DB_NAME +EOF + +echo "📦 安装依赖..." +pip3 install -q -r requirements.txt + +echo "🗄️ 运行数据库迁移..." +python3 manage.py migrate + +echo "🚀 启动服务(端口 $SERVICE_PORT)..." +# 杀掉旧进程 +pkill -f "python3 manage.py runserver $SERVICE_PORT" 2>/dev/null || true + +# 启动新服务 +mkdir -p ../logs +nohup python3 manage.py runserver 0.0.0.0:$SERVICE_PORT > ../logs/server.log 2>&1 & + +sleep 3 + +# 检查服务状态 +if curl -s "http://localhost:$SERVICE_PORT/api/stats/" > /dev/null; then + echo "✅ 服务启动成功!" + echo "📍 API 地址: http://localhost:$SERVICE_PORT/api/" + echo "📊 统计接口: http://localhost:$SERVICE_PORT/api/stats/" +else + echo "❌ 服务启动失败,查看日志:" + tail -20 ../logs/server.log + exit 1 +fi + +echo "" +echo "📝 常用命令:" +echo " 查看日志: tail -f $DEPLOY_DIR/logs/server.log" +echo " 停止服务: pkill -f 'python3 manage.py runserver $SERVICE_PORT'" +echo " 重启服务: bash $0" \ No newline at end of file