Commit 2b029f263c62a5a35c732e89040189cc6ef9802f

Authored by 胡龙江
1 parent 01351977

整理

1 -# Relay Server 部署打包脚本  
2 -# 运行: .\package-deploy.ps1  
3 -  
4 -$DeployDir = "$PSScriptRoot\deploy-package"  
5 -$ZipFile = "$PSScriptRoot\relay-server-deploy.zip"  
6 -  
7 -Write-Host "=== 打包 Relay Server 部署文件 ===" -ForegroundColor Cyan  
8 -  
9 -# 创建部署目录  
10 -if (Test-Path $DeployDir) { Remove-Item $DeployDir -Recurse -Force }  
11 -New-Item -ItemType Directory -Path $DeployDir | Out-Null  
12 -  
13 -# 复制必要文件  
14 -$files = @(  
15 - ".env",  
16 - "composer.json",  
17 - "docker-compose.yml",  
18 - "Dockerfile",  
19 - "migrate.php",  
20 - "start.php"  
21 -)  
22 -  
23 -foreach ($file in $files) {  
24 - Copy-Item "$PSScriptRoot\$file" "$DeployDir\" -Force  
25 - Write-Host " + $file" -ForegroundColor Green  
26 -}  
27 -  
28 -# 创建部署说明  
29 -$readme = @"  
30 -# Relay Server 部署指南  
31 -  
32 -## 1. 上传整个目录到服务器  
33 - scp -r . user@server:/opt/moltbot-relay  
34 -  
35 -## 2. 修改 .env 配置  
36 - - DB_HOST: 数据库地址  
37 - - DB_PASSWORD: 数据库密码  
38 - - REDIS_HOST: Redis 地址(使用 docker 内部网络可设为 redis)  
39 -  
40 -## 3. 启动服务  
41 - cd /opt/moltbot-relay  
42 - docker-compose up -d --build  
43 -  
44 -## 4. 查看日志  
45 - docker-compose logs -f  
46 -  
47 -## 5. 开放防火墙  
48 - firewall-cmd --permanent --add-port=8888/tcp  
49 - firewall-cmd --reload  
50 -  
51 -## 6. 修改本地插件配置  
52 - 编辑 ~/.clawdbot/clawdbot.json:  
53 - {  
54 - "channels": {  
55 - "wechat": {  
56 - "enabled": true,  
57 - "relayUrl": "ws://服务器IP:8888"  
58 - }  
59 - }  
60 - }  
61 -"@  
62 -$readme | Set-Content "$DeployDir\README.md" -Encoding UTF8  
63 -  
64 -# 打包成 zip  
65 -if (Test-Path $ZipFile) { Remove-Item $ZipFile -Force }  
66 -Compress-Archive -Path "$DeployDir\*" -DestinationPath $ZipFile  
67 -  
68 -Write-Host ""  
69 -Write-Host "=== 打包完成 ===" -ForegroundColor Green  
70 -Write-Host "部署包: $ZipFile" -ForegroundColor Yellow  
71 -Write-Host ""  
72 -Write-Host "将 zip 文件上传到服务器后解压并运行 docker-compose up -d --build" -ForegroundColor White  
73 -  
74 -# 清理临时目录  
75 -Remove-Item $DeployDir -Recurse -Force  
No preview for this file type
Please register or login to post a comment