TencentDB-Agent-Memory icon indicating copy to clipboard operation
TencentDB-Agent-Memory copied to clipboard

Hermes systemd 场景下 MEMORY_TENCENTDB_GATEWAY_CMD 使用 npx 容易找不到 node

Open kylezhang opened this issue 6 months ago • 2 comments

这次在服务器上接 Hermes + TencentDB Agent Memory 时,Memory Gateway 本身可以手动启动,但由 Hermes/systemd 自动拉起时失败。最后定位到 MEMORY_TENCENTDB_GATEWAY_CMD 里使用了裸 npx,而 systemd 环境没有加载 nvm 的 PATH。

环境

  • Ubuntu 服务器
  • Hermes gateway 作为 systemd service 运行
  • Node 通过 nvm 安装
  • 交互 shell 中:
command -v node
command -v npx

输出类似:

/root/.nvm/versions/node/v25.8.2/bin/node
/root/.nvm/versions/node/v25.8.2/bin/npx

现象

脚本写入的 Gateway 启动命令是:

sh -c 'cd ... && exec npx tsx src/gateway/server.ts'

在交互 shell 里手动执行可以跑起来,但 systemd 环境里会失败,日志里看到:

/usr/bin/env: 'node': No such file or directory

这时 curl http://127.0.0.1:8420/health 不通,Hermes 日志里会出现:

memory-tencentdb watchdog: Gateway unreachable; attempting to resurrect.
memory-tencentdb Gateway appears down; attempting to resurrect.

临时解决办法

我最后把 Memory Gateway 单独做成 systemd 服务,并显式写了 PATH 和 node 绝对路径:

Environment=PATH=/root/.nvm/versions/node/v25.8.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ExecStart=/root/.nvm/versions/node/v25.8.2/bin/node --import tsx/esm src/gateway/server.ts

这样可以正常启动,/health 返回:

{"status":"ok","version":"0.1.0","stores":{"vectorStore":true,"embeddingService":false}}

并且 Hermes 对话也已经写入:

/root/.memory-tencentdb/memory-tdai/conversations/2026-05-16.jsonl
/root/.memory-tencentdb/memory-tdai/vectors.db

建议

生成 MEMORY_TENCENTDB_GATEWAY_CMD 时,可以优先解析安装时的 node 绝对路径,例如:

NODE_BIN=$(command -v node)

然后写成:

sh -c 'cd <install_dir> && exec <absolute-node> --import tsx/esm src/gateway/server.ts'

这样比依赖 systemd 里的 npx/node PATH 更稳,尤其是 nvm/asdf 这类用户态 Node 安装方式。

kylezhang avatar May 16 '26 01:05 kylezhang

Hi @kylezhang,感谢反馈! 你建议的用 node 绝对路径替代 npx 的方案很合理,我们会评估该方案。感谢!🙏

Maxwell-Code07 avatar May 16 '26 04:05 Maxwell-Code07

问题已修复,随下个版本发出

noFloat avatar May 21 '26 09:05 noFloat