← Back to Plugins
Tools

Gateway Lifecycle

theo-lee1 By theo-lee1 👁 16 views ▲ 0 votes

Sends a Feishu card when the OpenClaw gateway (re)starts or shuts down. Independent OpenClaw plugin.

GitHub

Install

openclaw plugins install ./gateway-lifecycle

Configuration Example

{
  "plugins": {
    "entries": {
      "gateway-lifecycle": {
        "enabled": true,
        "hooks": {
          "allowConversationAccess": true
        }
      }
    }
  }
}

README

# gateway-lifecycle

OpenClaw gateway 启动 / 关闭时,给飞书发一张通知卡。
可以让你随时知道 gateway 什么时候被重启过。

> 依赖:飞书 IM、OpenClaw gateway 2026.5+。

## 安装

```bash
cd ~/.openclaw/plugins
git clone <repo-url> gateway-lifecycle
openclaw plugins install ./gateway-lifecycle --link
```

> 如果用打包版:直接 `openclaw plugins install ./gateway-lifecycle-0.1.0.tgz` 即可。

## 配置 `openclaw.json`

插件本身**不需要**配置参数(configSchema 都有 default),但**一个字段**必须加:

### 启用插件(**必填**)

OpenClaw 的安全策略要求**非内置插件**显式声明**允许访问会话内容**:

```jsonc
{
  "plugins": {
    "entries": {
      "gateway-lifecycle": {
        "enabled": true,
        "hooks": {
          "allowConversationAccess": true
        }
      }
    }
  }
}
```

> 飞书凭据写在 `openclaw.json` 的 `channels.feishu` 下:
>
> ```jsonc
> {
>   "channels": {
>     "feishu": {
>       "appId": "cli_xxxxxxxxxxxxxxxx",
>       "appSecret": "***"
>     }
>   }
> }
> ```

## 行为

| 事件 | 卡片 |
| --- | --- |
| 启动 | 🟢 网关已上线(含本次启动时间 + 上次启动时间) |
| 关闭 | 🔴 网关正在关闭(5 秒超时,最佳努力) |

收件人 = plugin 自己在 `message_received` 钩子里记录的活跃飞书 session。
路由有 30 分钟 TTL —— 30 分钟内**没有**消息进出的会话**不会**收到通知卡。

## 重启

```bash
# 如果用 systemd:
systemctl --user restart openclaw-gateway

# 如果是手动:
pkill -TERM -f "openclaw.*gateway"
sleep 6
nohup .../node .../dist/index.js gateway --port 18789 > /tmp/openclaw/manual-start.log 2>&1 &
disown
```

## 验证

启动后飞书应该出现一张"🟢 网关已上线"卡。
如果没出现:
1. 看 gateway 日志:
   ```bash
   tail -f /tmp/openclaw/openclaw-$(date +%F).log | grep -E "gateway-lifecycle"
   ```
2. 常见问题:
   - `no known feishu conversations; skipping up broadcast` → `message_received` 钩子**还没**收到过消息,**装完插件**先给 agent 发条消息再重启
   - `feishu auth failed` → `openclaw.json` 的 `channels.feishu` 配置问题
   - 卡片发到飞书了但收件人**不**对 → 看你 `message_received` 钩子里 route 选 candidate 的逻辑

## 可选配置

| Key | Default | 含义 |
| --- | --- | --- |
| `enabled` | `true` | 设为 `false` 整个插件不挂载 |
| `hooks.timeoutMs` | - | 单个 hook 最大执行时间(毫秒),默认 30000 |
| `config.httpTimeoutMs` | 10000 | 飞书 HTTP 请求超时(毫秒) |
| `config.feishuBaseUrl` | `https://open.feishu.cn` | Lark (海外) 改成 `https://open.larksuite.com` |

## 卸载

```bash
openclaw plugins uninstall gateway-lifecycle
rm -rf ~/.openclaw/plugins/gateway-lifecycle
rm -f ~/.openclaw/gateway-lifecycle.last-start.json
rm -f ~/.openclaw/gateway-lifecycle.routes.json
```
tools

Comments

Sign in to leave a comment

Loading comments...