使用项目:nostr relay 一个python写的程序
使用
pip
安装:pip install nostr-relay
新建一个目录
mkdir /opt/nostr
,并进入目录cd /opt/nostr
创建一个配置文件,参考官方默认配置 ,我的配置如下,修改了一点
DEBUG: false relay_name: python relay relay_description: relay written in python sysop_pubkey: sysop_contact: storage: sqlalchemy.url: sqlite+aiosqlite:///nostr.sqlite3 # the number of concurrent REQ queries sent to the db num_concurrent_reqs: 10 # the number of concurrent event saves. (sqlite can only support 1 writer at a time) num_concurrent_adds: 2 validators: - nostr_relay.validators.is_not_too_large - nostr_relay.validators.is_signed - nostr_relay.validators.is_recent - nostr_relay.validators.is_not_hellthread verification: # options are disabled, passive, enabled nip05_verification: disabled expiration: 86400 * 30 update_frequency: 3600 #blacklist: # - badhost.biz #whitelist: # - goodhost.com gunicorn: bind: 127.0.0.1:6969 workers: 1 loglevel: info reload: false purple: host: 127.0.0.1 port: 6969 workers: 1 disable_compression: true # see docs/authentication.md authentication: enabled: false relay_urls: - ws://localhost:6969 - ws://127.0.0.1:6969 # 可以换成 ws://公网IP:6969 - wss://yourdomain.name actions: save: a query: a # number of seconds to allow between client messages message_timeout: 1800 # number of open subscriptions per connection subscription_limit: 32 # set this to a private key used for internal control events # service_privatekey: 9627da965699a2a3048f97b77df5047e8cd0d11daca75e7687d0b28b65416a3c # set this to limit the number of events returned per REQ max_limit: 6000 # set this to the maximum number of "p" tags in an event hellthread_limit: 100
使用你喜欢的反向代理工具,配合域名使用。
使用systemd管理
创建service文件
vim /etc/systemd/system/nostr-relay.service
内容为
[Unit] Description=Nostr Relay Service After=network.target [Service] Type=simple User=root WorkingDirectory=/opt/nostr ExecStart=/usr/local/bin/nostr-relay -c /opt/nostr/config.yaml serve Restart=always RestartSec=5 StandardOutput=append:/opt/nostr/nostr-relay.log StandardError=append:/opt/nostr/nostr-relay-error.log [Install] WantedBy=multi-user.target
保存并退出。
重载systemd服务
systemctl daemon-reload
启动并查看运行情况
systemctl start nostr-relay systemctl status nostr-relay
设置开机自启
systemctl enable nostr-relay