Skip to content

Feature Request: Gateway lifecycle notifications (on_start / on_stop) #3279

Description

@piliplaker

Summary

当 Gateway 以 systemd 服务方式后台运行时,用户无法感知 Gateway 的启动和停止状态。特别是在 Restart=always 配置下,Gateway 会自动重启,但用户完全不知道服务是否正常运行。

Feature Request

希望在 Gateway 配置中支持生命周期通知钩子,例如:

{
  "gateway": {
    "on_start": "Gateway 已启动,准备接收消息 🟢",
    "on_stop": "Gateway 已停止 🔴"
  }
}
  • on_start: Gateway 完成初始化、所有 channel 连接成功后,通过已配置的 channel 发送通知
  • on_stop: Gateway 收到关闭信号后,通过 channel 发送通知

Why

  1. 后台运行无感知: systemd 部署后,用户无法直观判断 Gateway 是否在运行
  2. 自动重启无通知: Restart=always 导致重启时用户完全无感知
  3. systemd hook 方案不稳定: 尝试通过 ExecStartPost / ExecStopPost 调用外部脚本发送通知,但时序不可控(通知在 channel 连接建立之前就发出去了),消息无法送达

Environment

  • nanobot version: latest
  • Channel: WeChat (ilinkai)
  • Deployment: systemd service with Restart=always

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions