快速开始指南
从安装到运行中的 Nostr 中继只需几分钟:编写配置、校验、启动守护进程并运行首次健康检查。
1. 创建配置
nostrfy init 会写入一份带完整注释的默认 nostrfy.toml:
sh
nostrfy --config nostrfy.toml init用文本编辑器打开并调整 — 每个选项都有注释。
2. 校验配置
nostrfy check 强烈建议在启动前运行;如果哪里有问题,它会准确报告问题所在。
sh
nostrfy --config nostrfy.toml check3. 启动中继
sh
nostrfy --config nostrfy.toml start以守护进程方式运行。添加 --foreground 可在终端中运行。
然后用健康端点验证中继已启动:
sh
curl http://127.0.0.1:8080/health=> {"status":"ok"}
4. 将客户端指向它
在同一台机器上,连接到 ws://<host>:8080。默认主机是 127.0.0.1,只接受本地连接。要从其他机器访问中继,
请在配置中设置 server.host = "0.0.0.0":
toml
[server]
host = "0.0.0.0"要使用 wss://,需要在前端部署终止 TLS 的代理(nginx 或 Caddy)— 参见 部署文档。
5. 停止与重启
sh
nostrfy --config nostrfy.toml stop
nostrfy --config nostrfy.toml restart
kill -HUP $(cat nostrfy.pid) # reload the config without a restartrestart 会重新读取配置;SIGHUP 无需重启即可重载大部分设置。
有效运维
nostrfy stats显示实时统计 — 也可通过 HTTP 以/relay/stats和/metrics获取。- 日志写入
daemon.log_file并自动轮转。 RUST_LOG控制日志级别(例如RUST_LOG=nostrfy=debug)。