diff --git a/Makefile b/Makefile index 1af851082..572c19c17 100644 --- a/Makefile +++ b/Makefile @@ -103,6 +103,18 @@ install: install -C ./lotus-storage-miner /usr/local/bin/lotus-storage-miner install -C ./lotus-seal-worker /usr/local/bin/lotus-seal-worker +install-services: + install -C -m 0644 ./scripts/lotus-daemon.service /etc/systemd/system/lotus-daemon.service + install -C -m 0644 ./scripts/lotus-miner.service /etc/systemd/system/lotus-miner.service + systemctl daemon-reload + @echo + @echo "lotus and lotus-miner services installed. Don't forget to 'systemctl enable lotus|lotus-miner' for it to be enabled on startup." + +clean-services: + rm -f /etc/systemd/system/lotus-daemon.service + rm -f /etc/systemd/system/lotus-miner.service + systemctl daemon-reload + # TOOLS lotus-seed: $(BUILD_DEPS) diff --git a/documentation/en/install-systemd-services.md b/documentation/en/install-systemd-services.md new file mode 100644 index 000000000..8c83d56a1 --- /dev/null +++ b/documentation/en/install-systemd-services.md @@ -0,0 +1,29 @@ +# Lotus and Miner as a systemd service + +Lotus is capable of running as a systemd service daemon. You can find installable service files for systemd in the [lotus repo](https://github.com/filecoin-project/lotus/tree/master/scripts) as files with `.service` extension. In order to install these service files, you can copy these `.service` files to the default systemd service path. + +## Installing via `make` + +NOTE: Before using lotus and lotus-miner as systemd services, don't forget to `sudo make install` to ensure the binaries are accessible by the root user. + +If your host uses the default systemd service path, it can be installed with `sudo make install-services`: + +```sh +$ sudo make install-services +``` + +## Interacting with service logs + +Logs from the services can be reviewed using `journalctl`. + +### Follow logs from a specific service unit + +```sh +$ sudo journalctl -u lotus-daemon -f +``` + +### View logs in reverse order + +```sh +$ sudo journalctl -u lotus-miner -r +``` diff --git a/scripts/lotus-daemon.service b/scripts/lotus-daemon.service index 44b2058b0..86f0dff27 100644 --- a/scripts/lotus-daemon.service +++ b/scripts/lotus-daemon.service @@ -6,6 +6,10 @@ After=network.target ExecStart=/usr/local/bin/lotus daemon Environment=GOLOG_FILE="/var/log/lotus-daemon" Environment=GOLOG_LOG_FMT="json" +MemoryAccounting=true +MemoryHigh=8G +MemoryMax=10G +LimitNOFILE=8192:10240 [Install] WantedBy=multiuser.target