nimbus-eth2/docs/the_nimbus_book/src/beacon-node-systemd.md

73 lines
2.6 KiB
Markdown
Raw Normal View History

# Set up a systemd service
2020-08-06 11:55:57 +02:00
This page will take you through how to set up a `systemd` service for your beacon node.
2020-08-06 11:55:57 +02:00
Systemd is used in order to have a command or program run when your device boots (i.e. add it as a service). Once this is done, you can start/stop enable/disable from the linux prompt.
2020-08-06 11:55:57 +02:00
> [`systemd`](https://www.freedesktop.org/wiki/Software/systemd/) is a service manager designed specifically for Linux. There is no port to Mac OS. You can get more information from [https://www.raspberrypi.org/documentation/linux/usage/systemd.md](https://www.raspberrypi.org/documentation/linux/usage/systemd.md) or [https://fedoramagazine.org/what-is-an-init-system/](https://www.raspberrypi.org/documentation/linux/usage/systemd.md)
2020-08-06 11:55:57 +02:00
### 1. Create a systemd service
2020-08-06 11:55:57 +02:00
> ⚠️ If you wish to run the service with metrics enabled, you'll need to replace `--metrics:off` with `--metrics:on` in the service file below. See [here](./metrics-pretty-pictures.md) for more on metrics.
2021-05-22 11:13:27 +02:00
Create a `systemd` service unit file -- `nimbus-eth2-prater.service` -- and save it in `/lib/systemd/system/`.
2020-08-06 11:55:57 +02:00
The contents of the file should look like this:
```txt
[Unit]
Description=Nimbus beacon node
2020-08-06 11:55:57 +02:00
[Service]
WorkingDirectory=<BASE-DIRECTORY>
ExecStart=<BASE-DIRECTORY>/build/nimbus_beacon_node \
--non-interactive \
2021-05-22 11:13:27 +02:00
--network=prater \
--data-dir=build/data/shared_prater_0 \
--web3-url=<WEB3-URL> \
--rpc:on \
--metrics:off
User=<USERNAME>
Group=<USERNAME>
Restart=always
2020-08-06 11:55:57 +02:00
[Install]
WantedBy=default.target
```
2020-08-06 11:55:57 +02:00
Where you should replace:
2020-08-06 11:55:57 +02:00
`<BASE-DIRECTORY>` with the location of the `nimbus-eth2` repository on your device.
2020-08-06 11:55:57 +02:00
`<USERNAME>` with the username of the system user responsible for running the launched processes.
2020-08-06 11:55:57 +02:00
`<WEB3-URL>` with the WebSocket JSON-RPC URL you are planning to use.
> **N.B.** If you're running Nimbus on a Pi, your `<BASE-DIRECTORY>` is `/home/pi/nimbus-eth2/` and your `<USERNAME>` is `pi`
2020-08-06 11:55:57 +02:00
2021-05-22 11:13:27 +02:00
> If you want to run on mainnet, simply replace all instances of `prater` with `mainnet`. If you wish to run on `pyrmont`, replace all instances of `prater` with `pyrmont`.
2020-08-06 11:55:57 +02:00
### 2. Notify systemd of the newly added service
2020-08-06 11:55:57 +02:00
```console
sudo systemctl daemon-reload
2020-11-20 23:25:51 +01:00
```
### 3. Start the service
2020-11-20 23:25:51 +01:00
```console
2021-05-22 11:13:27 +02:00
sudo systemctl enable nimbus-eth2-prater --now
2020-08-06 11:55:57 +02:00
```
### 4. Monitor the service
```console
2021-05-22 11:13:27 +02:00
sudo journalctl -u nimbus-eth2-prater.service
```
This will show you the Nimbus logs at the default setting -- it should include regular "slot start" messages which will show your sync progress.
For more options, see [here](https://www.raspberrypi.org/documentation/linux/usage/systemd.md).
2021-05-22 11:13:27 +02:00