shareclaw 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- shareclaw-0.1.0/.env.example +32 -0
- shareclaw-0.1.0/.gitignore +20 -0
- shareclaw-0.1.0/DEPLOYMENT.md +565 -0
- shareclaw-0.1.0/LICENSE +21 -0
- shareclaw-0.1.0/PKG-INFO +358 -0
- shareclaw-0.1.0/README.en.md +330 -0
- shareclaw-0.1.0/README.md +328 -0
- shareclaw-0.1.0/docs/openclaw-isolation-guide.md +252 -0
- shareclaw-0.1.0/pyproject.toml +49 -0
- shareclaw-0.1.0/scripts/publish.sh +184 -0
- shareclaw-0.1.0/shareclaw/__init__.py +18 -0
- shareclaw-0.1.0/shareclaw/claw/__init__.py +29 -0
- shareclaw-0.1.0/shareclaw/claw/backend/__init__.py +28 -0
- shareclaw-0.1.0/shareclaw/claw/backend/base.py +136 -0
- shareclaw-0.1.0/shareclaw/claw/backend/local.py +214 -0
- shareclaw-0.1.0/shareclaw/claw/backend/remote.py +210 -0
- shareclaw-0.1.0/shareclaw/claw/commands.py +113 -0
- shareclaw-0.1.0/shareclaw/claw/queue.py +123 -0
- shareclaw-0.1.0/shareclaw/claw/rotate.py +209 -0
- shareclaw-0.1.0/shareclaw/claw/scheduler.py +128 -0
- shareclaw-0.1.0/shareclaw/cli.py +98 -0
- shareclaw-0.1.0/shareclaw/cloud/__init__.py +21 -0
- shareclaw-0.1.0/shareclaw/cloud/client.py +30 -0
- shareclaw-0.1.0/shareclaw/cloud/lighthouse.py +79 -0
- shareclaw-0.1.0/shareclaw/cloud/tat.py +113 -0
- shareclaw-0.1.0/shareclaw/config.py +89 -0
- shareclaw-0.1.0/shareclaw/server/__init__.py +10 -0
- shareclaw-0.1.0/shareclaw/server/app.py +50 -0
- shareclaw-0.1.0/shareclaw/server/routes.py +686 -0
- shareclaw-0.1.0/shareclaw/server/sse.py +18 -0
- shareclaw-0.1.0/shareclaw/server/templates/dashboard.html +445 -0
- shareclaw-0.1.0/shareclaw/server/templates/index.html +424 -0
- shareclaw-0.1.0/shareclaw/sharing/__init__.py +7 -0
- shareclaw-0.1.0/shareclaw/sharing/auto_rotate.py +126 -0
- shareclaw-0.1.0/shareclaw/sharing/invitation.py +109 -0
- shareclaw-0.1.0/shareclaw/sharing/store.py +171 -0
- shareclaw-0.1.0/shareclaw/sharing/user.py +178 -0
- shareclaw-0.1.0/shareclaw.png +0 -0
- shareclaw-0.1.0/tests/__init__.py +1 -0
- shareclaw-0.1.0/tests/test_config.py +115 -0
- shareclaw-0.1.0/tests/test_queue.py +221 -0
- shareclaw-0.1.0/tests/test_scheduler.py +65 -0
- shareclaw-0.1.0/tests/test_sse.py +24 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# 环境变量配置(复制此文件为 .env 并填入实际值)
|
|
2
|
+
|
|
3
|
+
# ========== 通用配置 ==========
|
|
4
|
+
# 部署模式:local(本地,默认)或 remote(远程)
|
|
5
|
+
SHARECLAW_MODE=local
|
|
6
|
+
# 队列最大长度(默认 6)
|
|
7
|
+
SHARECLAW_MAX_QUEUE_SIZE=6
|
|
8
|
+
|
|
9
|
+
# ========== 本地模式 (local) ==========
|
|
10
|
+
# OpenClaw 主目录(默认 ~/.openclaw)
|
|
11
|
+
# OPENCLAW_HOME=~/.openclaw
|
|
12
|
+
# ShareClaw 数据目录(默认 ~/.shareclaw)
|
|
13
|
+
# SHARECLAW_HOME=~/.shareclaw
|
|
14
|
+
|
|
15
|
+
# ========== 远程模式 (remote) ==========
|
|
16
|
+
# 腾讯云 API 密钥(前往 https://console.cloud.tencent.com/cam/capi 获取)
|
|
17
|
+
# TENCENT_SECRET_ID=你的SecretId
|
|
18
|
+
# TENCENT_SECRET_KEY=你的SecretKey
|
|
19
|
+
# Lighthouse 实例 ID(多个用逗号分隔)
|
|
20
|
+
# LIGHTHOUSE_INSTANCE_IDS=lhins-xxx1,lhins-xxx2 or ins-xxx
|
|
21
|
+
# Lighthouse 地域(默认 ap-guangzhou)
|
|
22
|
+
# LIGHTHOUSE_REGION=ap-guangzhou
|
|
23
|
+
|
|
24
|
+
# ========== 共享管理(可选,通过 Dashboard 配置) ==========
|
|
25
|
+
# 虾主管理密码(设置后 Dashboard 需要输入密码才能访问)
|
|
26
|
+
# 不设置则 Dashboard 无需密码(适合个人使用或内网环境)
|
|
27
|
+
# SHARECLAW_ADMIN_PASSWORD=your_password_here
|
|
28
|
+
# 以下配置也可以通过 http://<your-server>:9000/dashboard 的设置面板管理
|
|
29
|
+
# 每月服务器费用(用于费用分摊展示,默认 0)
|
|
30
|
+
# SHARECLAW_MONTHLY_COST=100
|
|
31
|
+
# 每人每日使用配额(小时,默认 8)
|
|
32
|
+
# SHARECLAW_DEFAULT_QUOTA_HOURS=8
|
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
# ShareClaw 正式环境部署指南
|
|
2
|
+
|
|
3
|
+
## 1. 适用范围
|
|
4
|
+
|
|
5
|
+
本文适用于以下场景:
|
|
6
|
+
|
|
7
|
+
- ShareClaw 与 OpenClaw 部署在同一台 Linux 服务器
|
|
8
|
+
- 使用 `local` 本地模式
|
|
9
|
+
- ShareClaw 需要以后台常驻服务运行
|
|
10
|
+
- 正式环境通过 Nginx 对外提供访问入口
|
|
11
|
+
|
|
12
|
+
本文以当前项目的实际实现为准,推荐采用以下运行方式:
|
|
13
|
+
|
|
14
|
+
- **与 OpenClaw 使用同一个 Linux 用户运行**
|
|
15
|
+
- **使用 `systemd --user` 托管 `shareclaw serve`**
|
|
16
|
+
- **通过 Nginx 反向代理对外暴露服务**
|
|
17
|
+
|
|
18
|
+
> 说明:当前版本默认 Web 启动入口是 `shareclaw serve`。本文不额外引入未纳入项目默认依赖的 WSGI 服务端,以确保文档与当前代码行为一致。
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 2. 部署原理与关键约束
|
|
23
|
+
|
|
24
|
+
本地模式下,ShareClaw 会直接操作 OpenClaw 的本地文件,并通过用户级 systemd 管理 OpenClaw Gateway。因此必须满足以下约束:
|
|
25
|
+
|
|
26
|
+
- ShareClaw 与 OpenClaw **必须使用同一个 Linux 用户**运行
|
|
27
|
+
- `openclaw` 命令必须在该用户的 `PATH` 中可执行
|
|
28
|
+
- `openclaw-gateway` 必须是**用户级服务**,并且以下命令能正常执行:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
systemctl --user restart openclaw-gateway
|
|
32
|
+
systemctl --user is-active openclaw-gateway
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- ShareClaw 运行用户必须对以下路径具备读写权限:
|
|
36
|
+
- `OPENCLAW_HOME/openclaw.json`
|
|
37
|
+
- `OPENCLAW_HOME/openclaw-weixin/accounts.json`
|
|
38
|
+
- `SHARECLAW_HOME/accounts_queue.json`
|
|
39
|
+
|
|
40
|
+
如果 `openclaw-gateway` 当前是系统级服务,而不是用户级服务,那么**当前版本的 ShareClaw 本地模式不建议直接上线**,因为代码内部调用的是 `systemctl --user`。
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 3. 推荐部署拓扑
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
Browser
|
|
48
|
+
|
|
|
49
|
+
v
|
|
50
|
+
Nginx (80/443)
|
|
51
|
+
|
|
|
52
|
+
v
|
|
53
|
+
127.0.0.1:9000 -> ShareClaw (`shareclaw serve`)
|
|
54
|
+
|
|
|
55
|
+
+-> 读写 ~/.openclaw/openclaw.json
|
|
56
|
+
+-> 读写 ~/.openclaw/openclaw-weixin/accounts.json
|
|
57
|
+
+-> 读写 ~/.shareclaw/accounts_queue.json
|
|
58
|
+
+-> 调用 `openclaw channels login --channel openclaw-weixin`
|
|
59
|
+
+-> 调用 `systemctl --user restart openclaw-gateway`
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 4. 目录规划建议
|
|
65
|
+
|
|
66
|
+
以下示例以部署用户 `ubuntu` 为例,请按实际用户名和目录调整。
|
|
67
|
+
|
|
68
|
+
建议目录如下:
|
|
69
|
+
|
|
70
|
+
```text
|
|
71
|
+
/opt/shareclaw/ShareClaw # 项目源码目录
|
|
72
|
+
/opt/shareclaw/venv # Python 虚拟环境
|
|
73
|
+
/home/ubuntu/.config/shareclaw/ # 环境变量文件目录
|
|
74
|
+
/home/ubuntu/.config/systemd/user/ # 用户级 systemd service 目录
|
|
75
|
+
/home/ubuntu/.openclaw/ # OpenClaw 主目录
|
|
76
|
+
/home/ubuntu/.shareclaw/ # ShareClaw 数据目录
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 5. 前置条件检查
|
|
82
|
+
|
|
83
|
+
正式部署前,请先以 **OpenClaw 实际运行用户** 执行以下检查。
|
|
84
|
+
|
|
85
|
+
### 5.1 检查 OpenClaw 命令
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
which openclaw
|
|
89
|
+
openclaw --help
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 5.2 检查 OpenClaw 用户级服务
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
systemctl --user status openclaw-gateway
|
|
96
|
+
systemctl --user is-active openclaw-gateway
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
期望结果中,`is-active` 返回:
|
|
100
|
+
|
|
101
|
+
```text
|
|
102
|
+
active
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 5.3 检查 OpenClaw 配置目录
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
ls -lah /home/ubuntu/.openclaw
|
|
109
|
+
ls -lah /home/ubuntu/.openclaw/openclaw-weixin
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
至少应能看到:
|
|
113
|
+
|
|
114
|
+
- `/home/ubuntu/.openclaw/openclaw.json`
|
|
115
|
+
- `/home/ubuntu/.openclaw/openclaw-weixin/accounts.json`
|
|
116
|
+
|
|
117
|
+
### 5.4 启用用户级服务开机常驻
|
|
118
|
+
|
|
119
|
+
为了让 `systemd --user` 在服务器重启后依然自动拉起服务,建议执行:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
sudo loginctl enable-linger ubuntu
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 6. 安装 ShareClaw
|
|
128
|
+
|
|
129
|
+
推荐使用**源码 + 虚拟环境**的方式部署,便于后续升级和回滚。
|
|
130
|
+
|
|
131
|
+
### 6.1 创建安装目录
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
sudo mkdir -p /opt/shareclaw
|
|
135
|
+
sudo chown -R ubuntu:ubuntu /opt/shareclaw
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 6.2 拉取代码
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
git clone https://github.com/gardennchen/ShareClaw.git /opt/shareclaw/ShareClaw
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 6.3 创建虚拟环境并安装
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
python3 -m venv /opt/shareclaw/venv
|
|
148
|
+
/opt/shareclaw/venv/bin/pip install -U pip
|
|
149
|
+
/opt/shareclaw/venv/bin/pip install -e /opt/shareclaw/ShareClaw
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
如果你的 `openclaw` 命令也安装在 Python 环境中,请确认它与 ShareClaw 使用的运行用户、运行环境一致。
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 7. 配置环境变量
|
|
157
|
+
|
|
158
|
+
### 7.1 创建环境文件目录
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
mkdir -p /home/ubuntu/.config/shareclaw
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 7.2 创建环境变量文件
|
|
165
|
+
|
|
166
|
+
创建文件:
|
|
167
|
+
|
|
168
|
+
```text
|
|
169
|
+
/home/ubuntu/.config/shareclaw/shareclaw.env
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
内容如下:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
SHARECLAW_MODE=local
|
|
176
|
+
OPENCLAW_HOME=/home/ubuntu/.openclaw
|
|
177
|
+
SHARECLAW_HOME=/home/ubuntu/.shareclaw
|
|
178
|
+
SHARECLAW_MAX_QUEUE_SIZE=6
|
|
179
|
+
PORT=9000
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 7.3 重要说明
|
|
183
|
+
|
|
184
|
+
- 当前版本**不会自动加载项目目录下的 `.env` 文件**
|
|
185
|
+
- 正式环境请通过以下任一方式注入环境变量:
|
|
186
|
+
- `systemd` 的 `EnvironmentFile=`
|
|
187
|
+
- 手动 `export`
|
|
188
|
+
- 在 `systemd` 环境文件中,**不要使用 `~`**,必须写**绝对路径**
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## 8. 先做一次前台启动验证
|
|
193
|
+
|
|
194
|
+
在配置后台服务前,建议先手工前台启动一次,确认环境正确。
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
export SHARECLAW_MODE=local
|
|
198
|
+
export OPENCLAW_HOME=/home/ubuntu/.openclaw
|
|
199
|
+
export SHARECLAW_HOME=/home/ubuntu/.shareclaw
|
|
200
|
+
export SHARECLAW_MAX_QUEUE_SIZE=6
|
|
201
|
+
export PATH=/home/ubuntu/.local/bin:/opt/shareclaw/venv/bin:/usr/local/bin:/usr/bin:/bin
|
|
202
|
+
|
|
203
|
+
/opt/shareclaw/venv/bin/shareclaw serve --host 127.0.0.1 --port 9000
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
另开一个终端验证健康检查:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
curl http://127.0.0.1:9000/health
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
期望返回:
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{"status":"ok"}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
如果这里不通,请先不要继续配置后台服务,优先排查环境变量、`PATH`、OpenClaw 权限和 `openclaw-gateway` 状态。
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## 9. 配置 `systemd --user` 后台服务
|
|
223
|
+
|
|
224
|
+
### 9.1 创建用户级 service 目录
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
mkdir -p /home/ubuntu/.config/systemd/user
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### 9.2 创建 service 文件
|
|
231
|
+
|
|
232
|
+
创建文件:
|
|
233
|
+
|
|
234
|
+
```text
|
|
235
|
+
/home/ubuntu/.config/systemd/user/shareclaw.service
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
内容如下:
|
|
239
|
+
|
|
240
|
+
```ini
|
|
241
|
+
[Unit]
|
|
242
|
+
Description=ShareClaw Web Service
|
|
243
|
+
After=network-online.target
|
|
244
|
+
Wants=network-online.target
|
|
245
|
+
|
|
246
|
+
[Service]
|
|
247
|
+
Type=simple
|
|
248
|
+
EnvironmentFile=/home/ubuntu/.config/shareclaw/shareclaw.env
|
|
249
|
+
Environment=PATH=/home/ubuntu/.local/bin:/opt/shareclaw/venv/bin:/usr/local/bin:/usr/bin:/bin
|
|
250
|
+
WorkingDirectory=/opt/shareclaw/ShareClaw
|
|
251
|
+
ExecStart=/opt/shareclaw/venv/bin/shareclaw serve --host 127.0.0.1 --port 9000
|
|
252
|
+
Restart=always
|
|
253
|
+
RestartSec=3
|
|
254
|
+
TimeoutStopSec=20
|
|
255
|
+
|
|
256
|
+
[Install]
|
|
257
|
+
WantedBy=default.target
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### 9.3 启动并设置开机自启
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
systemctl --user daemon-reload
|
|
264
|
+
systemctl --user enable --now shareclaw
|
|
265
|
+
systemctl --user status shareclaw
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### 9.4 查看日志
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
journalctl --user -u shareclaw -f
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## 10. 配置 Nginx 反向代理
|
|
277
|
+
|
|
278
|
+
正式环境建议仅让 ShareClaw 监听本机回环地址 `127.0.0.1:9000`,再由 Nginx 对外提供访问。
|
|
279
|
+
|
|
280
|
+
### 10.1 示例配置
|
|
281
|
+
|
|
282
|
+
以下以域名 `shareclaw.example.com` 为例:
|
|
283
|
+
|
|
284
|
+
```nginx
|
|
285
|
+
server {
|
|
286
|
+
listen 80;
|
|
287
|
+
server_name shareclaw.example.com;
|
|
288
|
+
|
|
289
|
+
location /rotate {
|
|
290
|
+
proxy_pass http://127.0.0.1:9000;
|
|
291
|
+
proxy_http_version 1.1;
|
|
292
|
+
proxy_set_header Host $host;
|
|
293
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
294
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
295
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
296
|
+
proxy_buffering off;
|
|
297
|
+
proxy_cache off;
|
|
298
|
+
proxy_read_timeout 3600s;
|
|
299
|
+
add_header X-Accel-Buffering no;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
location / {
|
|
303
|
+
proxy_pass http://127.0.0.1:9000;
|
|
304
|
+
proxy_http_version 1.1;
|
|
305
|
+
proxy_set_header Host $host;
|
|
306
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
307
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
308
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
309
|
+
proxy_read_timeout 300s;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### 10.2 SSE 特别说明
|
|
315
|
+
|
|
316
|
+
`/rotate` 接口使用的是 **SSE 流式返回**,因此 Nginx 必须关闭缓冲,否则前端可能无法实时看到:
|
|
317
|
+
|
|
318
|
+
- 轮转进度
|
|
319
|
+
- 二维码输出
|
|
320
|
+
- 最终完成事件
|
|
321
|
+
|
|
322
|
+
也就是说,以下配置非常关键:
|
|
323
|
+
|
|
324
|
+
```nginx
|
|
325
|
+
proxy_buffering off;
|
|
326
|
+
add_header X-Accel-Buffering no;
|
|
327
|
+
proxy_read_timeout 3600s;
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### 10.3 HTTPS 建议
|
|
331
|
+
|
|
332
|
+
正式环境建议为 Nginx 配置 HTTPS 证书,例如通过 Certbot 或现有网关统一接入 TLS。
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## 11. 启动后验证
|
|
337
|
+
|
|
338
|
+
### 11.1 验证本地服务
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
curl http://127.0.0.1:9000/health
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### 11.2 验证 Nginx 代理
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
curl http://shareclaw.example.com/health
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### 11.3 浏览器验证
|
|
351
|
+
|
|
352
|
+
打开以下地址:
|
|
353
|
+
|
|
354
|
+
```text
|
|
355
|
+
http://shareclaw.example.com/
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
你应能访问到前端页面。
|
|
359
|
+
|
|
360
|
+
### 11.4 接口列表
|
|
361
|
+
|
|
362
|
+
当前版本主要接口如下:
|
|
363
|
+
|
|
364
|
+
- `GET /`:前端测试页面
|
|
365
|
+
- `GET /health`:健康检查
|
|
366
|
+
- `GET|POST /rotate`:坐席轮转 SSE 接口
|
|
367
|
+
- `GET /logo.png`:前端 Logo 资源
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## 12. 日常运维命令
|
|
372
|
+
|
|
373
|
+
### 12.1 查看服务状态
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
systemctl --user status shareclaw
|
|
377
|
+
systemctl --user status openclaw-gateway
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### 12.2 重启服务
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
systemctl --user restart shareclaw
|
|
384
|
+
systemctl --user restart openclaw-gateway
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### 12.3 查看实时日志
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
journalctl --user -u shareclaw -f
|
|
391
|
+
journalctl --user -u openclaw-gateway -f
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### 12.4 查看当前监听端口
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
ss -lntp | grep 9000
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## 13. 数据文件位置说明
|
|
403
|
+
|
|
404
|
+
本地模式下,ShareClaw / OpenClaw 关键文件位置如下:
|
|
405
|
+
|
|
406
|
+
### 13.1 OpenClaw 配置文件
|
|
407
|
+
|
|
408
|
+
```text
|
|
409
|
+
OPENCLAW_HOME/openclaw.json
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
默认示例:
|
|
413
|
+
|
|
414
|
+
```text
|
|
415
|
+
/home/ubuntu/.openclaw/openclaw.json
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### 13.2 OpenClaw 账号文件
|
|
419
|
+
|
|
420
|
+
```text
|
|
421
|
+
OPENCLAW_HOME/openclaw-weixin/accounts.json
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
默认示例:
|
|
425
|
+
|
|
426
|
+
```text
|
|
427
|
+
/home/ubuntu/.openclaw/openclaw-weixin/accounts.json
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### 13.3 ShareClaw 队列文件
|
|
431
|
+
|
|
432
|
+
```text
|
|
433
|
+
SHARECLAW_HOME/accounts_queue.json
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
默认示例:
|
|
437
|
+
|
|
438
|
+
```text
|
|
439
|
+
/home/ubuntu/.shareclaw/accounts_queue.json
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
## 14. 常见问题排查
|
|
445
|
+
|
|
446
|
+
### 14.1 `systemctl --user restart openclaw-gateway` 失败
|
|
447
|
+
|
|
448
|
+
重点检查:
|
|
449
|
+
|
|
450
|
+
- ShareClaw 是否与 OpenClaw 使用同一用户运行
|
|
451
|
+
- `openclaw-gateway` 是否确实是用户级 service
|
|
452
|
+
- 是否已执行 `loginctl enable-linger <user>`
|
|
453
|
+
- 当前用户是否能直接执行:
|
|
454
|
+
|
|
455
|
+
```bash
|
|
456
|
+
systemctl --user restart openclaw-gateway
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### 14.2 后台服务启动成功,但轮转时报找不到 `openclaw`
|
|
460
|
+
|
|
461
|
+
这是典型的 `PATH` 问题。请检查 `shareclaw.service` 中的:
|
|
462
|
+
|
|
463
|
+
```ini
|
|
464
|
+
Environment=PATH=...
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
确认其中包含 `openclaw` 所在目录。
|
|
468
|
+
|
|
469
|
+
### 14.3 `.env` 文件明明存在,但配置没有生效
|
|
470
|
+
|
|
471
|
+
当前版本不会自动读取项目目录中的 `.env`。正式环境必须通过以下方式注入:
|
|
472
|
+
|
|
473
|
+
- `EnvironmentFile=`
|
|
474
|
+
- 手动 `export`
|
|
475
|
+
|
|
476
|
+
### 14.4 `/rotate` 无法实时输出进度或二维码
|
|
477
|
+
|
|
478
|
+
通常是 Nginx 开启了缓冲。请检查 `/rotate` 的反向代理配置中是否包含:
|
|
479
|
+
|
|
480
|
+
```nginx
|
|
481
|
+
proxy_buffering off;
|
|
482
|
+
add_header X-Accel-Buffering no;
|
|
483
|
+
proxy_read_timeout 3600s;
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
### 14.5 访问首页正常,但轮转失败
|
|
487
|
+
|
|
488
|
+
优先检查以下项目:
|
|
489
|
+
|
|
490
|
+
- `/home/ubuntu/.openclaw/openclaw.json` 是否存在
|
|
491
|
+
- `/home/ubuntu/.openclaw/openclaw-weixin/accounts.json` 是否存在且格式正确
|
|
492
|
+
- `openclaw channels login --channel openclaw-weixin` 是否可手工执行
|
|
493
|
+
- `openclaw-gateway` 当前是否为 `active`
|
|
494
|
+
|
|
495
|
+
### 14.6 服务重启后没有自动拉起
|
|
496
|
+
|
|
497
|
+
请检查:
|
|
498
|
+
|
|
499
|
+
```bash
|
|
500
|
+
systemctl --user is-enabled shareclaw
|
|
501
|
+
sudo loginctl show-user ubuntu
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
确认:
|
|
505
|
+
|
|
506
|
+
- `shareclaw` 已 `enable`
|
|
507
|
+
- 已启用 `linger`
|
|
508
|
+
|
|
509
|
+
---
|
|
510
|
+
|
|
511
|
+
## 15. 不推荐的部署方式
|
|
512
|
+
|
|
513
|
+
基于当前实现,以下方式不建议直接用于正式环境:
|
|
514
|
+
|
|
515
|
+
- **直接用 root 运行 ShareClaw**
|
|
516
|
+
- 原因:本地模式内部依赖 `systemctl --user`,root 的系统级服务上下文通常与 OpenClaw 用户上下文不一致
|
|
517
|
+
|
|
518
|
+
- **把 ShareClaw 做成系统级 service,但 OpenClaw 仍是用户级 service**
|
|
519
|
+
- 原因:ShareClaw 无法稳定管理目标用户下的 `openclaw-gateway`
|
|
520
|
+
|
|
521
|
+
- **只把环境变量写进项目目录 `.env`,却没有显式加载**
|
|
522
|
+
- 原因:当前版本不会自动读取 `.env`
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
## 16. 上线检查清单
|
|
527
|
+
|
|
528
|
+
上线前建议逐项确认:
|
|
529
|
+
|
|
530
|
+
- [ ] ShareClaw 与 OpenClaw 由同一个 Linux 用户运行
|
|
531
|
+
- [ ] `systemctl --user status openclaw-gateway` 正常
|
|
532
|
+
- [ ] `openclaw` 命令在服务 `PATH` 中可执行
|
|
533
|
+
- [ ] `OPENCLAW_HOME` 与 `SHARECLAW_HOME` 使用绝对路径
|
|
534
|
+
- [ ] `curl http://127.0.0.1:9000/health` 正常
|
|
535
|
+
- [ ] `systemctl --user status shareclaw` 正常
|
|
536
|
+
- [ ] Nginx 已配置 `/rotate` 的 SSE 无缓冲代理
|
|
537
|
+
- [ ] 已启用 `loginctl enable-linger <user>`
|
|
538
|
+
- [ ] 浏览器访问 `/`、`/health`、`/rotate` 均已验证
|
|
539
|
+
|
|
540
|
+
---
|
|
541
|
+
|
|
542
|
+
## 17. 附:最小可用部署步骤
|
|
543
|
+
|
|
544
|
+
如果你已经具备 OpenClaw 运行环境,只想快速落地正式环境,最小步骤如下:
|
|
545
|
+
|
|
546
|
+
1. 安装 ShareClaw 到虚拟环境
|
|
547
|
+
2. 创建 `/home/ubuntu/.config/shareclaw/shareclaw.env`
|
|
548
|
+
3. 创建 `/home/ubuntu/.config/systemd/user/shareclaw.service`
|
|
549
|
+
4. 执行:
|
|
550
|
+
|
|
551
|
+
```bash
|
|
552
|
+
systemctl --user daemon-reload
|
|
553
|
+
systemctl --user enable --now shareclaw
|
|
554
|
+
sudo loginctl enable-linger ubuntu
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
5. 配置 Nginx 代理到 `127.0.0.1:9000`
|
|
558
|
+
6. 验证:
|
|
559
|
+
|
|
560
|
+
```bash
|
|
561
|
+
curl http://127.0.0.1:9000/health
|
|
562
|
+
curl http://shareclaw.example.com/health
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
至此,即可完成本地模式下 ShareClaw 的正式环境部署。
|
shareclaw-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 garden
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|