And how can I have separate systemd services? Obviously, I could just have an electrs_mainnet.conf and an electrs_testnet.conf, but what about the systemd services? (I don't know much from Linux)
You can simply make 2 copies of electrs.service, one for main net and one for test net, then fill it with its own configuration. I'll give you an example below.
I should rephrase my words: Can you run both main net and test net at the same time from electrs? If yes, how?
Yes, what I mean is I'm able to run main net and test net with electrs at the same time.
Here is my configuration
Electrs configurations:
# Bitcoin Core settings
network = "bitcoin"
daemon_dir= "/home/bitcoin/.bitcoin"
daemon_rpc_addr = "127.0.0.1:8332"
# Electrs settings
electrum_rpc_addr = "127.0.0.1:50001"
db_dir = "/home/bitcoin/.electrs/db"
# Bitcoin Core settings
network = "testnet"
daemon_dir= "/home/bitcoin/.bitcoin"
daemon_rpc_addr = "127.0.0.1:18332"
# Electrs settings
electrum_rpc_addr = "127.0.0.1:60001"
db_dir = "/home/bitcoin/.electrs/db"
Here is what I mean by a separate systemd service. Electrs systemd units:
[Unit]
Description=Electrs daemon
Wants=bitcoind.service
After=bitcoind.service
[Service]
# Service execution
ExecStart=/usr/local/bin/electrs --conf /home/bitcoin/.electrs/electrs.conf
[Unit]
Description=Electrs testnet daemon
Wants=bitcoind-testnet.service
After=bitcoind-testnet.service
[Service]
ExecStart=/usr/local/bin/electrs --conf /home/bitcoin/.electrs/electrs-testnet.conf
Nginx Configurations:
upstream electrs {
server 127.0.0.1:50001;
}
upstream electrs-testnet {
server 127.0.0.1:60001;
}
server {
listen 50002 ssl;
proxy_pass electrs;
}
server {
listen 60002 ssl;
proxy_pass electrs-testnet;
}
I show the part where the lines are different(except the db_dir and daemon_dir), everything else is just the same as the Raspibolt tutorial. It all works fine whether it automatically started with systemd or with manually running the application (
electrs --conf=<config_file>).
Once I run electrs --conf=<config_file> while it already runs another network, it'll stop it to start with the other network.
It's hard to judge if I didn't know your configuration. If you are still interested to run both main net and test net, try to use my configurations, I'll try to help if something goes wrong.