Service
A service is a long-running process that can be started and stopped. It can be used to run background tasks, handle network requests, or interact with the system.
Create User
Create a new user called nostr
to run the relay service. Creating a new user is a good practice to isolate the service from the rest of the system.
Change ownership for data directory
Run script
Create a new file at /etc/systemd/system/nostr-relay.service
with the following content:
[Unit]
Description=Nostr Relay
After=network.target
[Service]
Type=simple
User=nostr
WorkingDirectory=/home/nostr
Environment=RUST_LOG=info,nostr_rs_relay=info
ExecStart=/usr/local/bin/nostr-rs-relay --config /etc/nostr-rs-relay/config.toml
Restart=on-failure
[Install]
WantedBy=multi-user.target
This script tells systemd to start the relay service as the nostr
user and restart it if it fails.
Start service
Start the service using the following commands:
The relay service should now be running. You can check the status of the service using the following command: